CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

Size: px
Start display at page:

Download "CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal"

Transcription

1 CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal Objectives: To gain experience with the programming of: 1. Graphical user interfaces (GUIs), 2. GUI components, and 3. Event handling (required for GUI programs). Notes: 1. This lab exercise correlates with Chapters 12 and 13 of the textbook. The most important sections are: and You need to understand what an event is and when an event occurs. You need to understand what is meant by event handling. 3. In the Java code of a program, be sure that you know how to register an event listener object with the GUI control for which it is to await (listen for) events. You should be able to write the code to have a listener method react/respond to an event generated by its associated GUI component. 4. In this exercise, we are dealing with two types of events: a. ActionEvent: Generated by hitting the Enter key in a JTextField. So an ActionListener object must be registered with the JTextFields. The method addactionlistener is used to register a listener object with a JTextField. b. ItemEvent: Generated by selecting an item from a JComboBox (drop list). So an ItemListener object must be registered with the JComboBoxes. The method additemlistener is used to register a listener object with a JComboBox. Lab Instructions: 1. Obtain the Java files, named EmployeeAryApplicJF.java and EmployeeAryApplicJFMain.java, from instructor s webpage. 2. Create a NetBeans project for this assignment. Add the instructor-provided files to the project. The Java class/file EmployeeAryApplicJFMain.java must be used as the main class/file. The file EmployeeAryApplicJF.java implements a JFrame window. Add your employee classes to the project. That is, add your Employee, HourlyEmployee, SalariedEmployee, and UnionEmployee classes to the project. Be sure that your employee classes fulfill the requirements (meet the specifications) of the previous assignments. 3. Add required constructor to your existing classes. To run the initial program provided by your instructor, each of your four employee classes must have a constructor that takes two parameters: String nam, int idnumb. If your classes do not have such a constructor, add the constructor to each (do not delete any of the constructors that you already have in the classes, however). 4. Compile and run the program. After entering some employees, the JFrame window looks like the window shown below. The data displayed for each employee should include all the member variables, even though they are not yet being set by the current version of the program. (You will add capabilities to do this.) The displayed information on each subclass employee must be generated by the inherited tostring method of the parent Employee class. Page 1 of 7

2 5. Extend the program. Now you will modify and extend the program as described in the following steps. 6. Mod 1. Add components (controls) to the GUI. Change the GridLayout to accommodate the additional GUI components that you will add in the steps below. In the modifications described in the following steps, all JLabels must be in the left-side column of the GridLayout, and the JTextFields and JComboBoxes must be in the right-side column. Enable user entry of employee s job title: o Add another JLabel to prompt for the employee s job title. o Add another JComboBox to enable the user to select the job title for the employee. o At the top of the main class, create an array of job title names that consists of the following: Administrative Assistant, Clerk, Engineer, Manager, Quality Engineer, Salesperson, Secretary, Service Specialist, Software Engineer, and Technician. This array is similar to the array of employee types, which is declared as a variable at the top of the main class. Both are arrays of Strings. o You need to declare an additional variable at the top of the main class to hold the value selected by the user via the new JComboBox (just like for the employee type when the user selects employee type from the corresponding JComboBox). For this variable, use the name selectedjobtitle. This additional variable is declared so as to have class scope since it must be referenced/used in the listener class and in the methods of the EmployeeAryApplicJF class. Page 2 of 7

3 Enable user entry of employee s pay rate: o Add another JLabel to prompt for the employee s pay rate. o Add another JTextField to enable the user to input the employee s pay rate. Enable user entry of employee s hours worked: o Add another JLabel to prompt for the employee s hours worked. o Add another JTextField to enable the user to input the employee s hours worked. 7. Mod 2. Wire up your new GUI components (controls) to event handlers. Register an event listener (handler) with each of the new GUI controls so that when the user triggers an event via the use of a control, the event handler will react to the event and cause the correct action to be taken by the program. This applies to the new additional JTextFields and the new additional JComboBox. The next bullet items cover this further. This means that if the user hits the Enter key in any of the newly added JTextFields, this should cause the new employee to be added to the array and to have the entire updated list of employees displayed in the JTextArea, just like hitting the Enter key in one of the existing JTextFields. You will need to modify and extend the method actionperformed in the MyActionListener class. When the user selects from the new JComboBox, this should trigger the updating of the contents of the job title variable (selectedjobtitle) declared at the top of the class. You will need to modify and extend the method itemstatechanged method in the MyItemListener class to accomplish the above. Be sure that the contents of all the JTextFields are cleared when the user hits the Enter key to trigger creation of the new additional employee. 8. Mod 3. In the addemployeetoarray method, modify the creation of employee instances. Depending on the type of employee selected by the user via the JComboBox (drop list), the program must create an instance of the correct employee subclass (HourlyEmployee, SalariedEmployee, or UnionEmployee), as it currently does. Your program must not create any instances of the top level Employee class. You must add parameters to the formal parameter list of the addemployeetoarray method. You must add parameters for: job title, pay rate, hours worked. When creating the employee instance, the code of this method must call the constructor in the correct subclass and pass the following parameters: name, id number, job title, pay rate, and hours worked. (You need to add this constructor in each class.) Do not pass employee type as a parameter. It is not necessary. Each class should initialize the employeetype variable without passing a parameter. Each class should know its type without passing a parameter. 9. Mod 4. Modify the call to the addemployeetoarray method. In the call to the addemployeetoarray method, add the actual parameters for job title, pay rate, hours worked. The total parameter list must consist of only the following items: name, id number, job title, pay rate, and hours worked. Page 3 of 7

4 10. Mod 4. Modify your employee classes. In each of your employee classes, add a constructor that has a parameter list that consists of a parameter for each of the following, and only the following: name, id number, job title, pay rate, and hours worked (as mentioned above). The constructor in the correct class with the above-mentioned parameter list must be called whenever an employee instance is created in your program. As stated in the above numbered step, do not pass employee type as a parameter. It is not necessary. Each class should initialize the employeetype variable without passing a parameter. Each class should know its type without passing a parameter Modify your employee classes so that the code is optimal. This means, for example, that you only add jobtitle as a protected variable in the parent Employee class and have the subclasses inherit this member variable. You should not add the job title as a member variable in any of the employee subclasses. No member variables should be declared in any of the subclasses. To clarify: the HourlyEmployee, SalariedEmployee, and UnionEmployee classes must only contain constructors and a computepay method, and nothing else. These three subclasses must not have a tostring method. You must have a tostring method in the top level Employee class, but not in any of the subclasses (not in the HourlyEmployee, SalariedEmployee, or UnionEmployee classes). Your Employee class must have a tostring method, but be sure that none of the other employee classes have a tostring method. Make sure that the tostring method returns a string that includes all of the following information items: employee s name, id number, employee type, job title, pay rate, hours worked, and computed pay. Be sure that the computepay method is called by the tostring method. The tostring method must not contain any math expressions that calculate pay. Furthermore, none of the classes should have logic that selects a compute pay method or formula based on whether hourly, salaried, or union. The employee type should not be passed as parameter to any of the constructors or methods in any of the employee classes or subclasses. Also, none of the classes or methods should have logic that selects an employee type or type name based on whether hourly, salaried, or union (or any representation of these such as ints or chars). Make sure that in the tostring method, all monetary amounts are formatted with a dollar sign and two digits to the right of the decimal point (as in previous exercises). Make sure that in the tostring method, the employee s hours worked value is formatted with two digits to the right of the decimal point (as in previous exercises). 11. Mod 5. Modify the code for the first JLabel for No. of Employees. Modify the code for this JLabel so that the maximum number of allowed employees is displayed in place of the question marks. The code must use the variable name for the max size of the array, and not the actual literal number. The use of the variable name is for maintainability. The literal should be in one place only. 12. Mod 6. Modify the Titled Border and contents of the JTextArea. Page 4 of 7

5 Change the text of the TitledBorder of the JTextArea to read XYZ Corporation Employees. Eliminate the line of text XYZ CORPORATION EMPLOYEES: from the text displayed within the JTextArea. The contents of the JTextArea should just be the list of employees with all attributes displayed for each employee. For each employee, display the employee s name, id number, employee type, job title, pay rate, hours worked, and computed pay. Make sure that all monetary amounts are formatted with a dollar sign and two digits to the right of the decimal point (as in previous exercises). This is done by the tostring method (see Item 10 above). Make sure that the employee s hours worked is formatted with two digits to the right of the decimal point (as in previous exercises). This is done by the tostring method (see Item 10 above). 13. Compile, execute, and debug the program. Test your program using a sufficient variety of data to make sure that it works on all cases. 14. Run the program and make window captures displaying all the capabilities of your program. See the window captures below for example program input/output displays. 15. Create batch file. Create a batch file as you did for the previous assignments so that your program can be executed without the use of NetBeans. Be sure that the batch file is within your top level NetBeans project folder. 16. Create ReadMe file. Using Microsoft Word, create a file named ReadMe. In this document, insert your name at the top, and on the next line insert the assignment number (e.g., Exercise #8 ). Then enter any comments regarding the assignment. Your comments might include any difficulties encountered, suggestions for improvement of the assignment, etc. Then insert at least two window captures of your JFrame window showing the inputs and outputs from the execution of the program. o The first window capture should be captured when you have entered data on the 4 th employee; it should show the data in the JTextFields and selected items in the JComboBoxes. o The second window capture should show the updated list of employees in the JTextArea that is the result of hitting the Enter key in one of the JTextFields for this new 4 th employee. If you did the extra credit part of the assignment, be sure to state this in your ReadMe file. (The extra credit portion of the exercise is specified below.) Also, include additional window captures that demonstrate the execution of the extra credit version of your program and its extra capabilities. Be sure the ReadMe document file is in your top level project folder. 17. Zip the project folder and all its contents. Create a zip file that contains the entire contents of your NetBeans project folder, including all sub-folders and files. Page 5 of 7

6 Your project folder should contain your ReadMe file and batch file, as for previous project assignments. Change the name the zip file so that its name consists of your name along with the assignment number, as follows: JohnJones-08.zip. Do not use spaces in the name of the file, use hyphens instead. 18. Extra Credit: In the main class for your project, in the constructor, add a JScrollPane to the GUI to hold the JTextArea. In order to accomplish this, do the following: Create an instance of the JScrollPane class. When invoking the JScrollPane constructor, pass the JTextArea as a parameter to the constructor so that the JTextArea is the component on the JScrollPane (the JScrollPane holds the JTextArea as its content). Add the JScrollPane to the JPanel instead of adding the JTextArea to the JPanel. The above addition of the JScrollPane should provide vertical scroll bars automatically when needed. For example, do not resize the main JFrame window. Then, after entering 4 employees, you will need to scroll vertically to see the data on some of the employees, since the JTextArea is only large enough to display the data on 4 employees. If you need more information, consult the Java 5.0 Documentation on the Java 2 Platform API Specification. TO RECEIVE CREDIT FOR YOUR ASSIGNMENT: Submit the following for credit to Angel Drop Box for Exercise 08: a. The zip file containing your entire NetBeans project folder with all its subfolders and files. b. You must have a batch file to run your program without using NetBeans, and the batch file must be in your top level project folder. c. You must have a ReadMe file that contains your name at the top, the lab number, any comments regarding the assignment, and window captures to show the program execution. The ReadMe file must be in the top level project folder. d. You must submit your zip file to the Lab08 Drop Box for this CS 209 course in Angel ( DUE DATE: Tuesday, March 28. EXAMPLE WINDOW CAPTURES FOR THE COMPLETED PROGRAM: See next page. The windows show the extra credit JScrollPane also. Page 6 of 7

7 Page 7 of 7

CS 209 Sec. 52 Spring, 2006 Lab 6 - B: Inheritance Instructor: J.G. Neal

CS 209 Sec. 52 Spring, 2006 Lab 6 - B: Inheritance Instructor: J.G. Neal CS 209 Sec. 52 Spring, 2006 Lab 6 - B: Inheritance Instructor: J.G. Neal Objectives. To gain experience with: 1. The creation of a simple hierarchy of classes. 2. The implementation and use of inheritance.

More information

CS 209 Spring, 2006 Lab 11: Files & Streams Instructor: J.G. Neal

CS 209 Spring, 2006 Lab 11: Files & Streams Instructor: J.G. Neal CS 209 Spring, 2006 Lab 11: Files & Streams Instructor: J.G. Neal Objectives: To gain experience with basic file input/output programming. Note: 1. This lab exercise corresponds to Chapter 16 of the textbook.

More information

Page 1 of 7. public class EmployeeAryAppletEx extends JApplet

Page 1 of 7. public class EmployeeAryAppletEx extends JApplet CS 209 Spring, 2006 Lab 9: Applets Instructor: J.G. Neal Objectives: To gain experience with: 1. Programming Java applets and the HTML page within which an applet is embedded. 2. The passing of parameters

More information

CS 209 Sec. 52 Spring, 2006 Lab 5: Classes Instructor: J.G. Neal

CS 209 Sec. 52 Spring, 2006 Lab 5: Classes Instructor: J.G. Neal CS 209 Sec. 52 Spring, 2006 Lab 5: Classes Instructor: J.G. Neal Objectives. To gain experience with: 1. The definition and use of a class to represent a real-world type of entity (an employee). 2. Adding

More information

CS 209 Sec. 52 Spring, 2006 Lab 4-A: Arrays Instructor: J.G. Neal Objectives: Lab Instructions: Obtain file ArrayDemoConsole.java

CS 209 Sec. 52 Spring, 2006 Lab 4-A: Arrays Instructor: J.G. Neal Objectives: Lab Instructions: Obtain file ArrayDemoConsole.java CS 209 Sec. 52 Spring, 2006 Lab 4-A: Arrays Instructor: J.G. Neal Objectives: To gain experience with: 1. The declaration, creation, and use of arrays. 2. Inserting/removing items into/from an array. 3.

More information

CoSc Lab # 6 (The Model) Due Date: Part I, Experiment classtime, Tuesday, Nov 6 th, 2018.

CoSc Lab # 6 (The Model) Due Date: Part I, Experiment classtime, Tuesday, Nov 6 th, 2018. CoSc 10403 Lab # 6 (The Model) Due Date: Part I, Experiment classtime, Tuesday, Nov 6 th, 2018. Part II, Program - by midnight, Tuesday, Nov 6 th, 2018. Again you will be required to "zip" together the

More information

CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: Lab Instructions: Log in Create folder CS209

CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: Lab Instructions: Log in Create folder CS209 CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: 1. To create a project in NetBeans. 2. To create, edit, compile, and run a Java program using NetBeans. 3. To

More information

CSE Lab 8 Assignment Note: This is the last lab for CSE 1341

CSE Lab 8 Assignment Note: This is the last lab for CSE 1341 CSE 1341 - Lab 8 Assignment Note: This is the last lab for CSE 1341 Pre-Lab : There is no pre-lab this week. Lab (100 points) The objective of Lab 8 is to get familiar with and utilize the wealth of Java

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 10(b): Working with Controls Agenda 2 Case study: TextFields and Labels Combo Boxes buttons List manipulation Radio buttons and checkboxes

More information

Event Driven Programming

Event Driven Programming Event Driven Programming Part 1 Introduction Chapter 12 CS 2334 University of Oklahoma Brian F. Veale 1 Graphical User Interfaces So far, we have only dealt with console-based programs Run from the console

More information

CS 209 Programming in Java #10 Exception Handling

CS 209 Programming in Java #10 Exception Handling CS 209 Programming in Java #10 Exception Handling Textbook Chapter 15 Spring, 2006 Instructor: J.G. Neal 1 Topics What is an Exception? Exception Handling Fundamentals Errors and Exceptions The try-catch-finally

More information

To gain experience using GUI components and listeners.

To gain experience using GUI components and listeners. Lab 5 Handout 7 CSCI 134: Fall, 2017 TextPlay Objective To gain experience using GUI components and listeners. Note 1: You may work with a partner on this lab. If you do, turn in only one lab with both

More information

Contents Chapter 1 Introduction to Programming and the Java Language

Contents Chapter 1 Introduction to Programming and the Java Language Chapter 1 Introduction to Programming and the Java Language 1.1 Basic Computer Concepts 5 1.1.1 Hardware 5 1.1.2 Operating Systems 8 1.1.3 Application Software 9 1.1.4 Computer Networks and the Internet

More information

Java IDE Programming-I

Java IDE Programming-I Java IDE Programming-I Graphical User Interface : is an interface that uses pictures and other graphic entities along with text, to interact with user. User can interact with GUI using mouse click/ or

More information

CS Exam 1 Review Suggestions

CS Exam 1 Review Suggestions CS 235 - Fall 2015 - Exam 1 Review Suggestions p. 1 last modified: 2015-09-30 CS 235 - Exam 1 Review Suggestions You are responsible for material covered in class sessions, lab exercises, and homeworks;

More information

CSE 1325 Project Description

CSE 1325 Project Description CSE 1325 Summer 2016 Object-Oriented and Event-driven Programming (Using Java) Instructor: Soumyava Das Graphical User Interface (GUI), Event Listeners and Handlers Project IV Assigned On: 07/28/2016 Due

More information

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming Objectives: Last revised 1/15/10 1. To introduce the notion of a component and some basic Swing components (JLabel, JTextField, JTextArea,

More information

DEMYSTIFYING PROGRAMMING: CHAPTER FOUR

DEMYSTIFYING PROGRAMMING: CHAPTER FOUR DEMYSTIFYING PROGRAMMING: CHAPTER FOUR Chapter Four: ACTION EVENT MODEL 1 Objectives 1 4.1 Additional GUI components 1 JLabel 1 JTextField 1 4.2 Inductive Pause 1 4.4 Events and Interaction 3 Establish

More information

SINGLE EVENT HANDLING

SINGLE EVENT HANDLING SINGLE EVENT HANDLING Event handling is the process of responding to asynchronous events as they occur during the program run. An event is an action that occurs externally to your program and to which

More information

Starting Out with Java: From Control Structures Through Objects Sixth Edition

Starting Out with Java: From Control Structures Through Objects Sixth Edition Starting Out with Java: From Control Structures Through Objects Sixth Edition Chapter 12 A First Look at GUI Applications Chapter Topics 12.1 Introduction 12.2 Creating Windows 12.3 Equipping GUI Classes

More information

Critical Thinking Assignment #6: Java Program #6 of 6 (70 Points)

Critical Thinking Assignment #6: Java Program #6 of 6 (70 Points) Critical Thinking Assignment #6: Java Program #6 of 6 (70 Points) Java Interactive GUI Application for Number Guessing with Colored Hints (based on Module 7 material) 1) Develop a Java application that

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 8(a): Abstract Classes Lecture Contents 2 Abstract base classes Concrete classes Dr. Amal Khalifa, 2014 Abstract Classes and Methods

More information

DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1

DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1 DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1 Objectives 1 6.1 Methods 1 void or return 1 Parameters 1 Invocation 1 Pass by value 1 6.2 GUI 2 JButton 2 6.3 Patterns

More information

Agenda. Container and Component

Agenda. Container and Component Agenda Types of GUI classes/objects Step-by-step guide to create a graphic user interface Step-by-step guide to event-handling PS5 Problem 1 PS5 Problem 2 Container and Component There are two types of

More information

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1 Java Swing based on slides by: Walter Milner Java Swing Walter Milner 2005: Slide 1 What is Swing? A group of 14 packages to do with the UI 451 classes as at 1.4 (!) Part of JFC Java Foundation Classes

More information

CS 134 Programming Exercise 7:

CS 134 Programming Exercise 7: CS 134 Programming Exercise 7: Scribbler Objective: To gain more experience using recursion and recursive data structures. This week, you will be implementing a program we call Scribbler. You have seen

More information

GUI Forms and Events, Part II

GUI Forms and Events, Part II GUI Forms and Events, Part II Quick Start Compile step once always mkdir labs javac PropertyTax6.java cd labs Execute step mkdir 6 java PropertyTax6 cd 6 cp../5/propertytax5.java PropertyTax6.java Submit

More information

CS 209 Spring, 2006 Lab 12: JAR Files Instructor: J.G. Neal

CS 209 Spring, 2006 Lab 12: JAR Files Instructor: J.G. Neal CS 209 Spring, 2006 Lab 12: JAR Files Instructor: J.G. Neal Objectives: To gain experience with the creation and use of JAR files, particularly for an applet. Notes: 1. This lab exercise corresponds to

More information

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING PROFESSOR GODFREY MUGANDA 1. Learn to Generate Random Numbers The class Random in Java can be used to create objects of the class

More information

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components

More information

Java Programming Lecture 6

Java Programming Lecture 6 Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"

More information

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun! Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques

More information

This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.

This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted. York University AS/AK/ITEC 2610 3.0 All Sections OBJECT-ORIENTED PROGRAMMING Midterm Test Duration: 90 Minutes This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for

More information

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons CompSci 125 Lecture 17 GUI: Graphics, Check Boxes, Radio Buttons Announcements GUI Review Review: Inheritance Subclass is a Parent class Includes parent s features May Extend May Modify extends! Parent

More information

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement

More information

Project 3. For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports.

Project 3. For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Project 3 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables

More information

Chapter 6: Graphical User Interfaces

Chapter 6: Graphical User Interfaces Chapter 6: Graphical User Interfaces CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 6: Graphical User Interfaces CS 121 1 / 36 Chapter 6 Topics

More information

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Systems Programming Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Leganés, 21st of March, 2014. Duration: 75 min. Full

More information

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski CS 190 - Java Introduction to Java Andy Mroczkowski uamroczk@cs.drexel.edu Department of Computer Science Drexel University March 10, 2008 / Lecture 8 Outline Course Status Course Information & Schedule

More information

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University Java Swing Recitation 11/(20,21)/2008 CS 180 Department of Computer Science, Purdue University Announcements Project 8 is out Milestone due on Dec 3rd, 10:00 pm Final due on Dec 10th, 10:00 pm No classes,

More information

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Frames, GUI and events Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Introduction to Swing The Java AWT (Abstract Window Toolkit)

More information

Review sheet for Final Exam (List of objectives for this course)

Review sheet for Final Exam (List of objectives for this course) Review sheet for Final Exam (List of objectives for this course) Please be sure to see other review sheets for this semester Please be sure to review tests from this semester Week 1 Introduction Chapter

More information

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student

More information

Java Programming Lecture 7

Java Programming Lecture 7 Java Programming Lecture 7 Alice E. Fischer Feb 16, 2015 Java Programming - L7... 1/16 Class Derivation Interfaces Examples Java Programming - L7... 2/16 Purpose of Derivation Class derivation is used

More information

Prototyping a Swing Interface with the Netbeans IDE GUI Editor

Prototyping a Swing Interface with the Netbeans IDE GUI Editor Prototyping a Swing Interface with the Netbeans IDE GUI Editor Netbeans provides an environment for creating Java applications including a module for GUI design. Here we assume that we have some existing

More information

We are on the GUI fast track path

We are on the GUI fast track path We are on the GUI fast track path Chapter 13: Exception Handling Skip for now Chapter 14: Abstract Classes and Interfaces Sections 1 9: ActionListener interface Chapter 15: Graphics Skip for now Chapter

More information

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming

More information

Programming graphics

Programming graphics Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it

More information

What Is an Event? Some event handler. ActionEvent. actionperformed(actionevent e) { }

What Is an Event? Some event handler. ActionEvent. actionperformed(actionevent e) { } CBOP3203 What Is an Event? Events Objects that describe what happened Event Sources The generator of an event Event Handlers A method that receives an event object, deciphers it, and processes the user

More information

CS180 Recitation. More about Objects and Methods

CS180 Recitation. More about Objects and Methods CS180 Recitation More about Objects and Methods Announcements Project3 issues Output did not match sample output. Make sure your code compiles. Otherwise it cannot be graded. Pay close attention to file

More information

Week Chapter Assignment SD Technology Standards. 1,2, Review Knowledge Check JP3.1. Program 5.1. Program 5.1. Program 5.2. Program 5.2. Program 5.

Week Chapter Assignment SD Technology Standards. 1,2, Review Knowledge Check JP3.1. Program 5.1. Program 5.1. Program 5.2. Program 5.2. Program 5. Week Chapter Assignment SD Technology Standards 1,2, Review JP3.1 Review exercises Debugging Exercises 3,4 Arrays, loops and layout managers. (5) Create and implement an external class Write code to create

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

1005ICT Object Oriented Programming Lecture Notes

1005ICT Object Oriented Programming Lecture Notes 1005ICT Object Oriented Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 20 GUI Components and Events This section develops a program

More information

Yanbu University College Applied Computer Science (ACS) Introduction to Computer Science (CS 102) Lab Exercise 10

Yanbu University College Applied Computer Science (ACS) Introduction to Computer Science (CS 102) Lab Exercise 10 Yanbu University College BACHELOR OF SCIENCE IN Applied Computer Science (ACS) Introduction to Computer Science (CS 102) Third Semester Academic Year 2011 2012 Lab Exercise 10 Course Instructor: Mohammed

More information

Graphical User Interfaces. Comp 152

Graphical User Interfaces. Comp 152 Graphical User Interfaces Comp 152 Procedural programming Execute line of code at a time Allowing for selection and repetition Call one function and then another. Can trace program execution on paper from

More information

Part I: Learn Common Graphics Components

Part I: Learn Common Graphics Components OOP GUI Components and Event Handling Page 1 Objectives 1. Practice creating and using graphical components. 2. Practice adding Event Listeners to handle the events and do something. 3. Learn how to connect

More information

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

More information

2IS45 Programming

2IS45 Programming Course Website Assignment Goals 2IS45 Programming http://www.win.tue.nl/~wsinswan/programmeren_2is45/ Rectangles Learn to use existing Abstract Data Types based on their contract (class Rectangle in Rectangle.

More information

News and info. Array. Feedback. Lab 4 is due this week. It should be easy to change the size of the game grid.

News and info. Array. Feedback. Lab 4 is due this week. It should be easy to change the size of the game grid. Calculation Applet! Arrays! Sorting! Java Examples! D0010E! Lecture 11! The GUI Containment Hierarchy! Mergesort! News and info Lab 4 is due this week. It should be easy to change the size of the game

More information

Window Interfaces Using Swing. Chapter 12

Window Interfaces Using Swing. Chapter 12 Window Interfaces Using Swing 1 Reminders Project 7 due Nov 17 @ 10:30 pm Project 6 grades released: regrades due by next Friday (11-18-2005) at midnight 2 GUIs - Graphical User Interfaces Windowing systems

More information

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM Introduction to the Assignment In this lab, you will finish the program to allow a user to solve Sudoku puzzles.

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

Chapter 12 Advanced GUIs and Graphics

Chapter 12 Advanced GUIs and Graphics Chapter 12 Advanced GUIs and Graphics Chapter Objectives Learn about applets Explore the class Graphics Learn about the classfont Explore the classcolor Java Programming: From Problem Analysis to Program

More information

Chapter 17 Creating User Interfaces

Chapter 17 Creating User Interfaces Chapter 17 Creating User Interfaces 1 Motivations A graphical user interface (GUI) makes a system user-friendly and easy to use. Creating a GUI requires creativity and knowledge of how GUI components work.

More information

Initial Coding Guidelines

Initial Coding Guidelines Initial Coding Guidelines ITK 168 (Lim) This handout specifies coding guidelines for programs in ITK 168. You are expected to follow these guidelines precisely for all lecture programs, and for lab programs.

More information

Graphics User Defined Forms, Part I

Graphics User Defined Forms, Part I Graphics User Defined Forms, Part I Quick Start Compile step once always mkdir labs javac PropertyTax5.java cd labs mkdir 5 Execute step cd 5 java PropertyTax5 cp /samples/csc/156/labs/5/*. cp PropertyTax1.java

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7 PROGRAMMING DESIGN USING JAVA (ITT 303) Graphical User Interface Unit 7 Learning Objectives At the end of this unit students should be able to: Build graphical user interfaces Create and manipulate buttons,

More information

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User CSE3461 Control Flow Paradigms: Reacting to the User Control Flow: Overview Definition of control flow: The sequence of execution of instructions in a program. Control flow is determined at run time by

More information

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7... Table of Contents Chapter 1 Getting Started with Java SE 7 1 Introduction of Java SE 7... 2 Exploring the Features of Java... 3 Exploring Features of Java SE 7... 4 Introducing Java Environment... 5 Explaining

More information

Class 16: The Swing Event Model

Class 16: The Swing Event Model Introduction to Computation and Problem Solving Class 16: The Swing Event Model Prof. Steven R. Lerman and Dr. V. Judson Harward 1 The Java Event Model Up until now, we have focused on GUI's to present

More information

Java Just in Time: Collected concepts after chapter 22

Java Just in Time: Collected concepts after chapter 22 Java Just in Time: Collected concepts after chapter 22 John Latham, School of Computer Science, Manchester University, UK. April 15, 2011 Contents 1 Computer basics 22000 1.1 Computer basics: hardware

More information

Swing/GUI Cheat Sheet

Swing/GUI Cheat Sheet General reminders To display a Swing component, you must: Swing/GUI Cheat Sheet Construct and initialize the component. Example: button = new JButton ("ButtonLabel"); Add it to the content pane of the

More information

Lab 10: Inheritance (I)

Lab 10: Inheritance (I) CS2370.03 Java Programming Spring 2005 Dr. Zhizhang Shen Background Lab 10: Inheritance (I) In this lab, we will try to understand the concept of inheritance, and its relation to polymorphism, better;

More information

EVENTS, EVENT SOURCES AND LISTENERS

EVENTS, EVENT SOURCES AND LISTENERS Java Programming EVENT HANDLING Arash Habibi Lashkari Ph.D. Candidate of UTM University Kuala Lumpur, Malaysia All Rights Reserved 2010, www.ahlashkari.com EVENTS, EVENT SOURCES AND LISTENERS Important

More information

CS 251 Intermediate Programming GUIs: Event Listeners

CS 251 Intermediate Programming GUIs: Event Listeners CS 251 Intermediate Programming GUIs: Event Listeners Brooke Chenoweth University of New Mexico Fall 2017 What is an Event Listener? A small class that implements a particular listener interface. Listener

More information

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008 Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object

More information

GUI Components Continued EECS 448

GUI Components Continued EECS 448 GUI Components Continued EECS 448 Lab Assignment In this lab you will create a simple text editor application in order to learn new GUI design concepts This text editor will be able to load and save text

More information

Contents Introduction 1

Contents Introduction 1 SELF-STUDY iii Introduction 1 Course Purpose... 1 Course Goals...1 Exercises... 2 Scenario-Based Learning... 3 Multimedia Overview... 3 Assessment... 3 Hardware and Software Requirements... 4 Chapter 1

More information

PIC 20A GUI with swing

PIC 20A GUI with swing PIC 20A GUI with swing Ernest Ryu UCLA Mathematics Last edited: November 22, 2017 Hello swing Let s create a JFrame. import javax. swing.*; public class Test { public static void main ( String [] args

More information

Index SELF-STUDY. Symbols

Index SELF-STUDY. Symbols SELF-STUDY 393 Index Symbols -... 239 "Event-to-property"... 144 "Faux" variables... 70 %... 239 ( )... 239 (Pme) paradigm... 14 *... 239 +... 239 /... 239 =... 239 = Null... 46 A A project... 24-25, 35

More information

Here are the steps to get the files for this project after logging in on acad/bill.

Here are the steps to get the files for this project after logging in on acad/bill. CSC 243, Java Programming, Spring 2013, Dr. Dale Parson Assignment 5, handling events in a working GUI ASSIGNMENT due by 11:59 PM on Thursday May 9 via gmake turnitin Here are the steps to get the files

More information

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13 CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling

More information

Enhanced Entity- Relationship Models (EER)

Enhanced Entity- Relationship Models (EER) Enhanced Entity- Relationship Models (EER) LECTURE 3 Dr. Philipp Leitner philipp.leitner@chalmers.se @xleitix LECTURE 3 Covers Small part of Chapter 3 Chapter 4 Please read this up until next lecture!

More information

Java Event Handling -- 1

Java Event Handling -- 1 Java Event Handling -- 1 Event Handling Happens every time a user interacts with a user interface. For example, when a user pushes a button, or types a character. 2 A Typical Situation: Scrollbar AWTEvent

More information

Final Examination Semester 3 / Year 2008

Final Examination Semester 3 / Year 2008 Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2008 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE CLASS : CS08-A + CS08-B LECTURER

More information

Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2011 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2011 COURSE COURSE CODE TIME DEPARTMENT LECTURER : JAVA PROGRAMMING : PROG1114 : 2 1/2 HOURS : COMPUTER SCIENCE : LIM PEI GEOK Student

More information

CMSC 150 Lab 8, Part II: Little PhotoShop of Horrors, Part Deux 10 Nov 2015

CMSC 150 Lab 8, Part II: Little PhotoShop of Horrors, Part Deux 10 Nov 2015 CMSC 150 Lab 8, Part II: Little PhotoShop of Horrors, Part Deux 10 Nov 2015 By now you should have completed the Open/Save/Quit portion of the menu options. Today we are going to finish implementing the

More information

Jonathan Aldrich Charlie Garrod

Jonathan Aldrich Charlie Garrod Principles of Software Construction: Objects, Design, and Concurrency (Part 3: Design Case Studies) Introduction to GUIs Jonathan Aldrich Charlie Garrod School of Computer Science 1 Administrivia Homework

More information

Java Just in Time: Collected concepts after chapter 18

Java Just in Time: Collected concepts after chapter 18 Java Just in Time: Collected concepts after chapter 18 John Latham, School of Computer Science, Manchester University, UK. April 15, 2011 Contents 1 Computer basics 18000 1.1 Computer basics: hardware

More information

Graphical Applications

Graphical Applications Graphical Applications The example programs we've explored thus far have been text-based They are called command-line applications, which interact with the user using simple text prompts Let's examine

More information

Graphical User Interfaces in Java - SWING

Graphical User Interfaces in Java - SWING Graphical User Interfaces in Java - SWING Graphical User Interfaces (GUI) Each graphical component that the user can see on the screen corresponds to an object of a class Component: Window Button Menu...

More information

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014 Introduction to GUIs Principles of Software Construction: Objects, Design, and Concurrency Jonathan Aldrich and Charlie Garrod Fall 2014 Slides copyright 2014 by Jonathan Aldrich, Charlie Garrod, Christian

More information

COMPSCI 230. Software Design and Construction. Swing

COMPSCI 230. Software Design and Construction. Swing COMPSCI 230 Software Design and Construction Swing 1 2013-04-17 Recap: SWING DESIGN PRINCIPLES 1. GUI is built as containment hierarchy of widgets (i.e. the parent-child nesting relation between them)

More information

CSCI 200 Lab 2 Inheritance, Polymorphism & Data Streams

CSCI 200 Lab 2 Inheritance, Polymorphism & Data Streams CSCI 200 Lab 2 Inheritance, Polymorphism & Data Streams In this lab you will write a set of simple Java interfaces and classes that use inheritance and polymorphism. You will also write code that uses

More information

Chapter 13 Lab Advanced GUI Applications

Chapter 13 Lab Advanced GUI Applications Gaddis_516907_Java 4/10/07 2:10 PM Page 113 Chapter 13 Lab Advanced GUI Applications Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Polymorphism 1 / 19 Introduction to Object-Oriented Programming Today we ll learn how to combine all the elements of object-oriented programming in the design of a program that handles a company payroll.

More information