1 Name & Gender Example At a certain University the registry require a small application to help those on the front desk work out the gender with the name.

Slides:



Advertisements
Similar presentations
JAVA Revision Lecture Electronic Voting System Marina De Vos.
Advertisements

L3:CSC © Dr. Basheer M. Nasef Lecture #3 By Dr. Basheer M. Nasef.
1 Chapter 8 Objects and Classes Lecture 2 Prepared by Muhanad Alkhalisy.
Introduction to Java Classes, events, GUI’s. Understand: How to use TextPad How to define a class or object How to create a GUI interface How event-driven.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
© The McGraw-Hill Companies, 2006 Chapter 18 Advanced graphics programming.
Chapter 11 Exception Handling and Event Handling.
Intro to Object-Oriented (“OO”) Design. OO Design Simplified methodology 1. Write down detailed description of problem 2. Identify all (relevant) nouns.
10.1 AWT The AWT classes Users today expect a Graphical User Interface (GUI) Improves application usability Difficult to implement cross-platform.
Advanced Java and Android Day 1 Object-Oriented Programming in Java Advanced Java and Android -- Day 11.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
1 Class 8. 2 Chapter Objectives Use Swing components to build the GUI for a Swing program Implement an ActionListener to handle events Add interface components.
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
CST JavaScript Validating Form Data with JavaScript.
MS3304: Week 4 PHP & HTML Forms. Overview HTML Forms elements refresher Sending data to a script via an HTML form –The post vs. get methods –Name value.
WEB FORM DESIGN. Creating forms for a web page For your web project you have to design a form for inclusion on your web site (the form information should.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 16.1 Test-Driving the Flag Quiz Application.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
JLabel, JTextField, JButton and JOptionPane
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 8 Objects and Classes.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
1 Lesson: Applets with User Input and Output with GUI ICS4M.
1.  At the end of this slide, student able to:  Object-Oriented Programming  Research on OOP features.  Do a code walkthrough to examine the implementation.
Applications Development
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
Chapter 8 Objects and Classes Object Oriented programming Instructor: Dr. Essam H. Houssein.
Topics Introduction Scene Graphs
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming – Home and reload buttons for the webbrowser, Applets.
Object-Oriented Programming (Java), Unit 28 Kirk Scott 1.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Objects and Classes.
Chapter 11 - A GUI Interacting With a Problem Domain Class1 Chapter 11 A GUI Interacting With a Problem Domain Class 11.
WEB FORM DESIGN. Creating forms for a web page For your web project you have to design a form for inclusion on your web site (the form information should.
Session 6 Comments on Lab 3 & Implications of Inheritance.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Enhanced Inventory Application.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Learning Aim C.  In this section we will look at how text, tables, forms and frames can be used in web pages.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
1 4.2 Selection Logical Operators. 2 Learning Objectives Explain how the logical operator AND Boolean statements works. Directly testing if text boxes.
Notes for Assignment #2 Assn2: GUI Database Interface Corresponds with Chapters 28, 29, 31.
Informatics Computer School CS114 Web Publishing HTML Lesson 4.
Java Visual Applications CSIS 3701: Advanced Object Oriented Programming.
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Chapter 5 Validating Form Data with JavaScript
Java FX: Scene Builder.
A First Look at GUI Applications Radio Buttons and Check Boxes
Topics Graphical User Interfaces Using the tkinter Module
Java Primer 1: Types, Classes and Operators
Java Programming: From Problem Analysis to Program Design,
Using local variable without initialization is an error.
Chapter 8 Objects and Classes Part 1
Exception Handling and Event Handling
Constructors, GUI’s(Using Swing) and ActionListner
CS360 Client/Server Programming Using Java
Chapter 5 Processing Input with Applets
Java Programming Language
Presentation transcript:

1 Name & Gender Example At a certain University the registry require a small application to help those on the front desk work out the gender with the name. The student enters their family name and gender The application then gives the name and gender

2 Possible Design Gender & Name read read name Label TextField Male/female radio button submit accept data Button calculatedisplay display name+gender Label TextField clear clear all text Button GUI elements female male enter name submit clear

3 MethodGUI calculate WorkOut

4 How does the MethodGUI use the auxiliary class WorkOut? First attempt would be to set up a ‘calculating’ class with a method to work out the name and gender It would be sent the values for the 2 inputs and return the name and gender It would not hold any data of its own and would really only be a glorified function holding the calculating method only

5 MethodGUI calculate Workout String name, boolean genderStatus String who

6 Code for the GUI ( 3 parts) setting up all the GUI features. declaring their types and constructing new objects with the correct parameters Constructing all GUI elements

7 setting up the JFrame adding all the GUI elements to the content pane registering the buttons with the listeners adding all GUI elements Code for the GUI (part 2)

8 Code for the GUI (part 3) resetting all the text fields to empty strings when the clear button is selected takes the information from the GUI and uses it to call the method of the auxiliary class places the return value back on the frame Setting up the events triggered by the GUI elements

The Auxiliary Class 9 Why is this static?

10 Design for the Calculator part The calculator will receive 2 pieces of data –The name (name) –the gender status (gStatus) It will return the name & gender (name, gStatus)(n, g) MethodGUI (who) (return)

11 Alternative Solution Although this first attempt works, it is not good Java style and does not really make use of the object oriented power of the language Leaving the JFrame GUI construction as it is, the changes to this new solution involve the creation of an object of the Workout class which holds its own data so can be given values for its instance variables When the call to use the auxiliary class is made the values needed are passed by the call and assigned to the instance variables either using ‘set’ methods of the auxiliary class or directly

12 MethodGUI2 and Workout2 created an object called genderWorker of the type Workout2 i.e. an instance of the class Workout2 using the parameters we have got from the GUI to construct it We then use a method of that object to find the gender & name The changed code in the GUI is :

13 data members of the class (instance variables) Workout2 name : String gStatus : boolean +Workout2(named:String,status:boolean) +calcWho() : String The value of named is assigned from the constructor to the instance variable name This value of name can then be used by the calcWho method directly in the object without being passed explicitly the class constructor needing 2 parameters