Event-driven Programming, Separation of Concerns, the Observer pattern and the JavaFX Event Infrastructure

Size: px
Start display at page:

Download "Event-driven Programming, Separation of Concerns, the Observer pattern and the JavaFX Event Infrastructure"

Transcription

1 Java GUIs in JavaFX Event-driven Programming, Separation of Concerns, the Observer pattern and the JavaFX Event Infrastructure 1

2 GUIs process inputs and deliver outputs for a computing system Inputs Click a button to perform an operation Type keys to provide text or set values Move to a new focus (another control) Drag/select visual components Accept different inputs that mean the same Outputs Show a graph of a value over time Display text, graphics, images Present audio Display a system value in various ways 2

3 JavaFX Event Class Hierarchy A user stimulates the system through the GUI The GUI generates events for the stimulus The GUI forwards those events to handlers 3 Handlers fulfill the system function

4 javafx.event.eventhandler EventHandler<T extends Event> class The interface for handlers has one method. void handle(t event) It is therefore a functional interface. The class Control allows registering of EventHandlers void addeventhandler( ) We will stick to ActionEvents. setonaction( EventHandler<ActionEvent> eh) For Button, ChoiceBox, TextField,... 4

5 Adding and Removing a Handler Also Called 'registering' and 'unregistering' Methods are found in javafx.scene.node JavaFX GUI objects interact with each other To add a handler (advanced): addeventhandler( EventType<T> eventtype, EventHandler<? super T> eventhandler) To remove a handler: 5 removeeventhandler( EventType<T> eventtype, EventHandler<? super T> eventhandler)

6 Division of Responsibility GUI controls accept input stimuli But should a Button do the work to respond? A Button won't then be reusable GUI views display system values/state What decides how to show that state? A value could be shown as text or a graphic or both at different times or for different audiences 6

7 System Design Divide a system into components Modular design tells us this Assign tasks to components to organize it Divide and conquer! A component should do one thing well Focus like a laser on its job Then make the components communicate That means the GUI must tell other components what the user wants, and display to the user what is happening elsewhere. 7

8 Separation of Concerns Goal: Keep IO and Operation domains separate External Input/Output Domain Domain of Operation Show Act Upon GUI Component System Component User or other system 8 Events happen between components here Provide support for value displays and input entry And here Provide application response to input and output delivery

9 Example External Input/Output Domain Domain of Operation See text Press button Button( Take Action ) ok listener or event handler that was added to button EventHandler< ActionEvent> User or other system handle( ActionEvent ) { System.out.println( ok ); } 9

10 Subject-Observer Pattern Closely related to event handling is the Observer Pattern. A Subject sets itself up to be 'seen' by other objects the Observers that want to view An Observer calls the subject to add itself as a listener for changes to the subject 12 The subject notifies its observers when the subject changes state by calling a standard method update() on its observers Observer's update decides how to respond Decouple the subject from details of observer.

11 Observer Pattern 13 [10/2017]

12 Updates and Notifications We can write Observer code (observer) that is told when a GUI event happens. Button clicked, call the observers (handlers). But remember the GUI has no observable state. The true Observer case is when the state of the actual application (model) changes Change can be internally/externally caused In this case, the Observable (subject) needs to tell the GUI that something changed source? 14 mutating action Application Base Model update GUI Component (observer)

13 Observer Pattern Java's Observer pattern is in java.util The Observer interface: void update(observable o, Object arg) extra data passed from observable to observers Major methods of the Observable class: 15 void addobserver(observer o) void notifyobservers() void notifyobservers(object arg) void setchanged()...

14 Model-View-Controller: Decoupling a GUI from its Subject A GUI presents information to the 16 outside world May change at different rate from system A GUI's Input processing feeds data and commands into the system Needs an interface to operate through The Subject system operates on input and produces output Does not want to tie tightly to any one display because there may be different evolving needs Provides an interface for feeding data and commands in and sending results out Evolves separately from the view and the control of input

15 Model-View-Controller: Decoupling a GUI from its Subject View VIEW Components Major boundary is between the problem domain and the user interface. Model defines the connection points. Physical Action Model uses abstract interfaces. Control should provide visual feedback. For example a button shows a visible response to a click. MODEL Components 17 CONTROL Components Control and View interact with the model through a specific problem interface.

16 notify Sequence of Calls in CounterGUI Button event handler GUI Application TextField Counter(model) push (inside JavaFX) increment update getcount settext 18 Note that this all happens on one thread!

17 Java Event Thread The thread that runs the event handling on the previous slide is an event thread created by Application. No other thread may make updates (like settext) on GUI elements created by the Application subclass. If that has to happen, queue up your update by calling JavaFX's runlater method: Platform.runLater( () mylabel.settext( ) ); 19

18 Model-View-Controller: Choices for implementation Use a classic console interface. Still the best choice for some types of work. Really. Use Swing and AWT event handling This is a legacy approach, still often used. JavaFX: several approaches Java general-utility tools java.util.observer and java.util.observable Javafx tools and approaches EventHandler and EventFilter javafx.beans properties sophisticated, but complicated to learn 20

Event Handling in JavaFX

Event Handling in JavaFX Event Handling in JavaFX Event Driven Programming Graphics applications use events. An event dispatcher receives events and notifies interested objects. Event Listener Event EventQueue 1. ActionEvent 2.

More information

CSE 331. Model/View Separation and Observer Pattern

CSE 331. Model/View Separation and Observer Pattern CSE 331 Model/View Separation and Observer Pattern slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/ 1 Model and

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

Composite Pattern Diagram. Explanation. JavaFX Subclass Hierarchy, cont. JavaFX: Node. JavaFX Layout Classes. Top-Level Containers 10/12/2018

Composite Pattern Diagram. Explanation. JavaFX Subclass Hierarchy, cont. JavaFX: Node. JavaFX Layout Classes. Top-Level Containers 10/12/2018 Explanation Component has Operation( ), which is a method that applies to all components, whether composite or leaf. There are generally many operations. Component also has composite methods: Add( ), Remove(

More information

event driven programming user input Week 2 : c. JavaFX user input Programming of Interactive Systems

event driven programming user input Week 2 : c. JavaFX user input Programming of Interactive Systems Programming of Interactive Systems Week 2 : c. JavaFX user input Anastasia.Bezerianos@lri.fr Anastasia.Bezerianos@lri.fr (part of this class is based on previous classes from Anastasia, and of T. Tsandilas,

More information

https://www.eclipse.org/efxclipse/install.html#for-the-lazy

https://www.eclipse.org/efxclipse/install.html#for-the-lazy CSC40232: SOFTWARE ENGINEERING Professor: Jane Cleland Huang Lecture 4: Getting Started with Java FX Wednesday, January 30 th and February 1 st sarec.nd.edu/courses/se2017 Department of Computer Science

More information

Outline. Design Patterns. Observer Pattern. Definitions & Classifications

Outline. Design Patterns. Observer Pattern. Definitions & Classifications Outline Design Patterns Definitions & Classifications Observer Pattern Intent Motivation Structure Participants Collaborations Consequences Implementation 1 What is a Design Pattern describes a problem

More information

CST141 JavaFX Events and Animation Page 1

CST141 JavaFX Events and Animation Page 1 CST141 JavaFX Events and Animation Page 1 1 2 3 4 5 6 7 JavaFX Events and Animation CST141 Event Handling GUI components generate events when users interact with controls Typical events include: Clicking

More information

Event-Driven Programming with GUIs. Slides derived (or copied) from slides created by Rick Mercer for CSc 335

Event-Driven Programming with GUIs. Slides derived (or copied) from slides created by Rick Mercer for CSc 335 Event-Driven Programming with GUIs Slides derived (or copied) from slides created by Rick Mercer for CSc 335 Event Driven GUIs A Graphical User Interface (GUI) presents a graphical view of an application

More information

CSE 331 Software Design and Implementation. Lecture 16 Callbacks and Observers

CSE 331 Software Design and Implementation. Lecture 16 Callbacks and Observers CSE 331 Software Design and Implementation Lecture 16 Callbacks and Observers Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 6 due Thursday 8/2 Homework 7 due Thursday 8/2 Callbacks The

More information

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in Lab 4 D0010E Object-Oriented Programming and Design Lecture 9 Lab 4: You will implement a game that can be played over the Internet. The networking part has already been written. Among other things, the

More information

Observer Pattern. CS580 Advanced Software Engineering October 31, Yu Sun, Ph.D.

Observer Pattern. CS580 Advanced Software Engineering   October 31, Yu Sun, Ph.D. Observer Pattern CS580 Advanced Software Engineering http://cs356.yusun.io October 31, 2014 Yu Sun, Ph.D. http://yusun.io yusun@csupomona.edu Announcements Quiz 5 Singleton Pattern Abstract Factory Pattern

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

CSC 161 LAB 3-1 JAVA FX CALCULATOR

CSC 161 LAB 3-1 JAVA FX CALCULATOR CSC 161 LAB 3-1 JAVA FX CALCULATOR PROFESSOR GODFREY MUGANDA 1. Introduction and Overview In this lab, you are going to use JavaFX to create a calculator that can add, subtract, divide, multiply, and find

More information

Week 12 Thursday. For milestone #2 and #3, also submit a screenshot of your GUI once it is launched.

Week 12 Thursday. For milestone #2 and #3, also submit a screenshot of your GUI once it is launched. Week 12 Thursday D-Teams have been created Create your A-Team by Friday, or let me know to assign you earlier. Team Project: Tournament-Bracket (D-Team 30 pts) Milestone #1: due before 10pm THIS Friday,

More information

Example: CharCheck. That s It??! What do you imagine happens after main() finishes?

Example: CharCheck. That s It??! What do you imagine happens after main() finishes? Event-Driven Software Paradigm Today Finish Programming Unit: Discuss Graphics In the old days, computers did exactly what the programmer said Once started, it would run automagically until done Then you

More information

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Module 4 Multi threaded Programming, Event Handling OOC 4 th Sem, B Div 2017-18 Prof. Mouna M. Naravani Event Handling Complete Reference 7 th ed. Chapter No. 22 Event Handling Any program that uses a

More information

CSE 331 Software Design and Implementation. Lecture 17 Events, Listeners, Callbacks

CSE 331 Software Design and Implementation. Lecture 17 Events, Listeners, Callbacks CSE 331 Software Design and Implementation Lecture 17 Events, Listeners, Callbacks Zach Tatlock / Winter 2016 The limits of scaling What prevents us from building huge, intricate structures that work perfectly

More information

Real World. static methods and Console & JavaFX App Intros. Lecture 16. Go ahead and PULL Lecture Materials & Sign-in on PollEv

Real World. static methods and Console & JavaFX App Intros. Lecture 16. Go ahead and PULL Lecture Materials & Sign-in on PollEv Go ahead and PULL Lecture Materials & Sign-in on PollEv Poll Everywhere: pollev.com/comp110 Lecture 16 static methods and Console & JavaFX App Intros Real World Spring 2016 Today Our first apps without

More information

IT 313 Advanced Application Development

IT 313 Advanced Application Development Page 1 of 10 IT 313 Advanced Application Development Final Exam -- March 13, 2016 Part A. Multiple Choice Questions. Answer all questions. You may supply a reason or show work for partial credit. 5 points

More information

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Module 4 Multi threaded Programming, Event Handling OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani Event Handling Any program that uses a graphical user interface, such as a Java application written

More information

Distributed Collaboration - Assignment 1: Multi-View 1-User IM

Distributed Collaboration - Assignment 1: Multi-View 1-User IM Distributed Collaboration - Assignment 1: Multi-View 1-User IM Date Assigned:??? 1-View Target Date:??? Multi-View Submission Date:??? Objectives: Understand the use of observer pattern in user -interface

More information

Java Programming. Events and Listeners

Java Programming. Events and Listeners Java Programming Events and Listeners Alice E. Fischer April 19, 2015 Java Programming - Events and Listenersldots 1/12 Events and Listeners An event is generated when The user clicks a GUI button or CheckBox

More information

are most specifically concerned with

are most specifically concerned with Observer Behavioral Patterns Behavioral patterns are those patterns that are most specifically concerned with communication between objects Introduction Name Observer Also Known As Dependents, Publish-Subscribe

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

MIT AITI Swing Event Model Lecture 17

MIT AITI Swing Event Model Lecture 17 MIT AITI 2004 Swing Event Model Lecture 17 The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the user. But how do GUIs interact with users? How do applications

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

Java. Error, Exception, and Event Handling. Error, exception and event handling. Error and exception handling in Java

Java. Error, Exception, and Event Handling. Error, exception and event handling. Error and exception handling in Java Computer Science Error, Exception, and Event Handling Java 02/23/2010 CPSC 449 228 Unless otherwise noted, all artwork and illustrations by either Rob Kremer or Jörg Denzinger (course instructors) Error,

More information

2.6 Error, exception and event handling

2.6 Error, exception and event handling 2.6 Error, exception and event handling There are conditions that have to be fulfilled by a program that sometimes are not fulfilled, which causes a so-called program error. When an error occurs usually

More information

Event Driven Programming

Event Driven Programming Event Driven Programming 1. Objectives... 2 2. Definitions... 2 3. Event-Driven Style of Programming... 2 4. Event Polling Model... 3 5. Java's Event Delegation Model... 5 6. How to Implement an Event

More information

Introduction to concurrency and GUIs

Introduction to concurrency and GUIs Principles of Software Construction: Objects, Design, and Concurrency Part 2: Designing (Sub)systems Introduction to concurrency and GUIs Charlie Garrod Bogdan Vasilescu School of Computer Science 1 Administrivia

More information

Lecture 19 GUI Events

Lecture 19 GUI Events CSE 331 Software Design and Implementation Lecture 19 GUI Events The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous inner classes Proper interaction

More information

Java FX. Threads, Workers and Tasks

Java FX. Threads, Workers and Tasks Java FX Threads, Workers and Tasks Threads and related topics Lecture Overview...but first lets take a look at a good example of Model - View - Controler set up This and most of the lecture is taken from

More information

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation CSE 331 Software Design & Implementation Hal Perkins Spring 2017 GUI Event-Driven Programming 1 The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous

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

Case studies: Outline Case Study: Noughts and Crosses

Case studies: Outline Case Study: Noughts and Crosses I. Automated Banking System Case studies: Outline Case Study: Noughts and Crosses II. III. Library Noughts and Crosses Definition of the problem Game played on a 3x3 square board between two players. The

More information

Design Patterns Design patterns advantages:

Design Patterns Design patterns advantages: Design Patterns Designing object-oriented software is hard, and designing reusable object oriented software is even harder. You must find pertinent objects factor them into classes at the right granularity

More information

CS 112 Programming 2. Lecture 14. Event-Driven Programming & Animations (1) Chapter 15 Event-Driven Programming and Animations

CS 112 Programming 2. Lecture 14. Event-Driven Programming & Animations (1) Chapter 15 Event-Driven Programming and Animations CS 112 Programming 2 Lecture 14 Event-Driven Programming & Animations (1) Chapter 15 Event-Driven Programming and Animations rights reserved. 2 Motivations Suppose you want to write a GUI program that

More information

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of Computer Science Technische Universität Darmstadt Dr.

More information

Event-driven Programming: GUIs

Event-driven Programming: GUIs Dr. Sarah Abraham University of Texas at Austin Computer Science Department Event-driven Programming: GUIs Elements of Graphics CS324e Spring 2018 Event-driven Programming Programming model where code

More information

Model-View Controller IAT351

Model-View Controller IAT351 Model-View Controller IAT351 Week 17 Lecture 1 15.10.2012 Lyn Bartram lyn@sfu.ca Administrivia CHANGE to assignments and grading 4 assignments This one (Assignment 3) is worth 20% Assignment 4 is worth

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

CS5010 PDP Introduction to Design. Maria Zontak. Slides inspired by slides of H.Perkins (UW, CS331) and MIT software engineering course

CS5010 PDP Introduction to Design. Maria Zontak. Slides inspired by slides of H.Perkins (UW, CS331) and MIT software engineering course CS5010 PDP Introduction to Design Maria Zontak Slides inspired by slides of H.Perkins (UW, CS331) and MIT 16.355 software engineering course Disclaimer Design - a creative problem-solving. Bad news: No

More information

6 The MVC model. Main concepts to be covered. Pattern structure. Using design patterns. Design pattern: Observer. Observers

6 The MVC model. Main concepts to be covered. Pattern structure. Using design patterns. Design pattern: Observer. Observers Main concepts to be covered 6 The MVC model Design patterns The design pattern The architecture Using design patterns Inter-class relationships are important, and can be complex. Some relationship recur

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

Tecniche di Progettazione: Design Patterns

Tecniche di Progettazione: Design Patterns Tecniche di Progettazione: Design Patterns GoF: MVC e Observer 1 The Observer Pattern Intent Define a one-to-many dependency between objects so that when one object changes state, all its dependents are

More information

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals

More information

Solution register itself

Solution register itself Observer Pattern Context: One object (the Subject) is the source of events. Other objects (Observers) want to know when an event occurs. Or: several objects should be immediately updated when the state

More information

02. OBSERVER PATTERN. Keep your Objects in the know. Don t miss out when something interesting happens

02. OBSERVER PATTERN. Keep your Objects in the know. Don t miss out when something interesting happens BIM492 DESIGN PATTERNS 02. OBSERVER PATTERN Keep your Objects in the know Don t miss out when something interesting happens Congrats! Your team has just won the contract to build Weather-O-Rama, Inc. s

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

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing. COSC User Interfaces Module 3 Sequential vs. Event-driven Programming Example Programs DemoLargestConsole.java DemoLargestGUI.java Demo programs will be available on the course web page. GUI Program Organization

More information

CSE 331 Software Design and Implementation. Lecture 19 GUI Events

CSE 331 Software Design and Implementation. Lecture 19 GUI Events CSE 331 Software Design and Implementation Lecture 19 GUI Events Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 7 due Thursday 8/9 Homework 8 due Thursday 8/9 HW8 has a regression testing

More information

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline Sequential vs. Event-driven Programming Reacting to the user GUI Program Organization Let s digress briefly to examine the organization of our GUI programs We ll do this in stages, by examining three example

More information

Observer pattern. Somebody s watching me...

Observer pattern. Somebody s watching me... Observer pattern Somebody s watching me... Purpose of the Observer pattern You have an object, Subject whose state many other objects are interested in. In particular, the many other objects are interested

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

Outline. Observer Pattern: Pitfalls. Observer Applications

Outline. Observer Pattern: Pitfalls. Observer Applications Outline Observer Pattern: Pitfalls NotifyObservers Invocation Problem M:N Problem ConcurrentModificationException Problem Cyclic Dependency Problem Causality of State Changes Problem Memory Management

More information

Building Graphical User Interfaces with the MVC Pattern

Building Graphical User Interfaces with the MVC Pattern Building Graphical User Interfaces with the MVC Pattern Joseph Bergin Pace University jbergin@pace.edu The Model View Controller pattern was invented in a Smalltalk context for decoupling the graphical

More information

CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community

CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Suppose we are talking about the depth-first search (DFS) algorithm. Nodes are added to

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

Chapter 15 Event-Driven Programming and Animations

Chapter 15 Event-Driven Programming and Animations Chapter 15 Event-Driven Programming and Animations 1 Motivations Suppose you want to write a GUI program that lets the user enter a loan amount, annual interest rate, and number of years and click the

More information

SYSC Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

SYSC Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work. It is most beneficial to you to write this mock midterm UNDER EXAM CONDITIONS. This means: Complete the Exam in 3 hour(s). Work on your own. Keep your notes and textbook closed. Attempt every question.

More information

Graphical User Interface (Part-1) Supplementary Material for CPSC 233

Graphical User Interface (Part-1) Supplementary Material for CPSC 233 Graphical User Interface (Part-1) Supplementary Material for CPSC 233 Introduction to Swing A GUI (graphical user interface) is a windowing system that interacts with the user The Java AWT (Abstract Window

More information

46 Advanced Java for Bioinformatics, WS 17/18, D. Huson, December 21, 2017

46 Advanced Java for Bioinformatics, WS 17/18, D. Huson, December 21, 2017 46 Advanced Java for Bioinformatics, WS 17/18, D. Huson, December 21, 2017 11 FXML and CSS A program intended for interactive use may provide a large number of user interface (UI) components, as shown

More information

GUI Programming. Chapter. A Fresh Graduate s Guide to Software Development Tools and Technologies

GUI Programming. Chapter. A Fresh Graduate s Guide to Software Development Tools and Technologies A Fresh Graduate s Guide to Software Development Tools and Technologies Chapter 12 GUI Programming CHAPTER AUTHORS Ang Ming You Ching Sieh Yuan Francis Tam Pua Xuan Zhan Software Development Tools and

More information

CS 116x Winter 2015 Craig S. Kaplan. Module 03 Graphical User Interfaces. Topics

CS 116x Winter 2015 Craig S. Kaplan. Module 03 Graphical User Interfaces. Topics CS 116x Winter 2015 Craig S. Kaplan Module 03 Graphical User Interfaces Topics The model-view-controller paradigm Direct manipulation User interface toolkits Building interfaces with ControlP5 Readings

More information

Lecture 5. Lecture

Lecture 5. Lecture this GUI Example: SignalGUI Orphans D0010E Object- Oriented Programming and Design Model- View- Control Example: Counter Observer Recursive References Design PaOerns - Håkan Jonsson 1 1 About dynamic objects

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

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages. 1 CS257 Computer Science I Kevin Sahr, PhD Lecture 14: Graphical User Interfaces Command-Line Applications 2 The programs we've explored thus far have been text-based applications A Java application is

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

A reusable design concept

A reusable design concept References: Xiaoping Jia, Object-Oriented Software Development Using Java;Douglas C.Schmidt, Design Pattern Case Studies with C++;Bruce E.Wampler,The Essence of Object-Oriented Programming with Java and

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

Design Patterns. it s about the Observer pattern, the Command pattern, MVC, and some GUI. some more

Design Patterns. it s about the Observer pattern, the Command pattern, MVC, and some GUI. some more Lecture: Software Engineering, Winter Semester 2011/2012 some more Design Patterns it s about the Observer pattern, the Command pattern, MVC, and some GUI Design Pattern *...+ describes a problem which

More information

7. Program Frameworks

7. Program Frameworks 7. Program Frameworks Overview: 7.1 Introduction to program frameworks 7.2 Program frameworks for User Interfaces: - Architectural properties of GUIs - Abstract Window Toolkit of Java Many software systems

More information

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Thursday 12:00 PM 2:00 PM Friday 8:30 AM 10:30 AM OR request appointment via e-mail

More information

A set, collection, group, or configuration containing members regarded as having certain attributes or traits in common.

A set, collection, group, or configuration containing members regarded as having certain attributes or traits in common. Chapter 6 Class Action In Chapter 1, we explained that Java uses the word class to refer to A set, collection, group, or configuration containing members regarded as having certain attributes or traits

More information

The Observer Pattern

The Observer Pattern COP 4814 Florida International University Kip Irvine The Observer Pattern Updated: 2/25/2012 Based on Head-First Design Patterns, Chapter 2 Overview Why observers are necessary Who generates and observes

More information

CS112 Lecture: Reuse, Packages, Patterns

CS112 Lecture: Reuse, Packages, Patterns CS112 Lecture: Reuse, Packages, Patterns Revised 4/20/05 Objectives: 1. To introduce the idea of re-use 2. To introduce some characteristics that make classes re-usable 3. To introduce Java packages. 4.

More information

DCS235 Software Engineering Exercise Sheet 2: Introducing GUI Programming

DCS235 Software Engineering Exercise Sheet 2: Introducing GUI Programming Prerequisites Aims DCS235 Software Engineering Exercise Sheet 2: Introducing GUI Programming Version 1.1, October 2003 You should be familiar with the basic Java, including the use of classes. The luej

More information

Beyond CSE143. What s Left To Do? Templates. Using Templates. A Template Class. A Problem with Reusing Code CSE 143

Beyond CSE143. What s Left To Do? Templates. Using Templates. A Template Class. A Problem with Reusing Code CSE 143 What s Left To Do? Beyond CSE143 Templates Modern Software Development Windows and Java 143 Wrapup Beyond the C++ covered in this course Many topics, many more details of topics we did cover Main omission:

More information

ITNP090 - Object Oriented Software Design

ITNP090 - Object Oriented Software Design In this practical, we will create a model for a part of the reservation system for a library. There are Book objects and an application object that creates and manipulates them. Two view objects in the

More information

Lecture 4: UI Software Architecture. Fall UI Design and Implementation 1

Lecture 4: UI Software Architecture. Fall UI Design and Implementation 1 Lecture 4: UI Software Architecture Fall 2006 6.831 UI Design and Implementation 1 1 UI Hall of Fame or Shame? Source: Interface Hall of Shame Fall 2006 6.831 UI Design and Implementation 2 This message

More information

Advanced Java for Bioinformatics Winter 2017/18. Prof. Daniel Huson

Advanced Java for Bioinformatics Winter 2017/18. Prof. Daniel Huson Advanced Java for Bioinformatics, WS 17/18, D. Huson, November 8, 2017 1 1 Introduction Advanced Java for Bioinformatics Winter 2017/18 Prof. Daniel Huson Office hours: Thursdays 17-18h (Sand 14, C310a)

More information

Asynchronous Programming

Asynchronous Programming Asynchronous Programming Turn-in Instructions A main file, called gui.py See previous slides for how to make it main I ll run it from the command line Put in a ZIP file, along with any additional needed

More information

TO DO: Create a new class which adds statistics to the dice. NOTE: Don t forget to run regression tests

TO DO: Create a new class which adds statistics to the dice. NOTE: Don t forget to run regression tests TO DO: Create a new class which adds statistics to the dice This class should add functionality to store the roll frequencies. You should implement a validation test (as well as running unit tests) as

More information

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright GUI Basics Object Orientated Programming in Java Benjamin Kenwright Outline Essential Graphical User Interface (GUI) Concepts Libraries, Implementation, Mechanics,.. Abstract Windowing Toolkit (AWT) Java

More information

Charlie Garrod Michael Hilton

Charlie Garrod Michael Hilton Principles of So3ware Construc9on: Objects, Design, and Concurrency Part 3: Design case studies Introduc9on to concurrency and GUIs Charlie Garrod Michael Hilton School of Computer Science 1 Administrivia

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

Studying software design patterns is an effective way to learn from the experience of others

Studying software design patterns is an effective way to learn from the experience of others Studying software design patterns is an effective way to learn from the experience of others 1 Parties have different ways of presenting the results. Presentation of results Coupling Computation of results

More information

Module dependences and decoupling (Events, listeners, callbacks)

Module dependences and decoupling (Events, listeners, callbacks) Module dependences and decoupling (Events, listeners, callbacks) CSE 331 University of Washington Michael Ernst The limits of scaling What prevents us from building huge, intricate structures that work

More information

Example: not good design. Motivation for MVC. public class BankAccount extends JPanel implements ActionListener

Example: not good design. Motivation for MVC. public class BankAccount extends JPanel implements ActionListener References: Teach Yourself Programming in 21 Days, Anthony Sintes; Rick Mercer;Beginning Java Objects, Jacquie Barker; 3/2/2004 1 Motivation for MVC Decoupled UIs are good One model may have several user

More information

Chapter 14. Exception Handling and Event Handling ISBN

Chapter 14. Exception Handling and Event Handling ISBN Chapter 14 Exception Handling and Event Handling ISBN 0-321-49362-1 Chapter 14 Topics Introduction to Exception Handling Exception Handling in Ada Exception Handling in C++ Exception Handling in Java Introduction

More information

Programming Language Concepts: Lecture 8

Programming Language Concepts: Lecture 8 Programming Language Concepts: Lecture 8 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 8, 11 February 2009 GUIs and event

More information

Microthread. An Object Behavioral Pattern for Managing Object Execution. 1.0 Intent. 2.0 Also Known As. 3.0 Classification. 4.0 Motivation/Example

Microthread. An Object Behavioral Pattern for Managing Object Execution. 1.0 Intent. 2.0 Also Known As. 3.0 Classification. 4.0 Motivation/Example Microthread An Object Behavioral Pattern for Managing Object Execution Joe Hoffert and Kenneth Goldman {joeh,kjg}@cs.wustl.edu Distributed Programing Environments Group Department of Computer Science,

More information

Introducing Application Design and Software Engineering Principles in Introductory CS Courses: Model-View-Controller Java Application Framework

Introducing Application Design and Software Engineering Principles in Introductory CS Courses: Model-View-Controller Java Application Framework Introducing Application Design and Software Engineering Principles in Introductory CS Courses: Model-View-Controller Java Application Framework Scot F. Morse Division of Computer Science Western Oregon

More information

GUI Event Handlers (Part I)

GUI Event Handlers (Part I) GUI Event Handlers (Part I) 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda General event

More information

implementation support

implementation support Implementation support chapter 8 implementation support programming tools levels of services for programmers windowing systems core support for separate and simultaneous usersystem activity programming

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

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) )

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) ) COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) ) Course Evaluations Please do these. -Fast to do -Used to

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

CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING Expression Tree Case Study : Prototype Pattern Reactor pattern

CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING Expression Tree Case Study : Prototype Pattern Reactor pattern CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING 2011 Expression Tree Case Study : Prototype Pattern Reactor pattern CLONING OBJECTS Cloning permits replicating an object C++ assignment operator implements a

More information