Event Driven Systems and Modeling

Slides:



Advertisements
Similar presentations
Event handling and listeners What is an event? user actions and context event sources and listeners Why should my programs be event- driven? User interaction.
Advertisements

Mari Göransson - KaU - Datavetenskap - DAVD11 1 Java Event Handling --
Event Handling. In this class we will cover: Basics of event handling The AWT event hierarchy Semantic and low-level events in the AWT.
Event Handling Events and Listeners Timers and Animation.
Unit 12 Object-oriented programming: Event-driven programming for GUI Jin Sa.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
Welcome to CIS 083 ! Events CIS 068.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
C H A P T E R T E N Event-Driven Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Lab 6: event & input intro User Interface Lab: GUI Lab Oct. 2 nd, 2013.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 14 Event-Driven Programming.
Dale Roberts GUI Programming using Java - Event Handling Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Copyright © 2002, Systems and Computer Engineering, Carleton University EventModel.ppt * Object-Oriented Software Development Part 17.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 12 Event-Driven Programming.
Computer Science [3] Java Programming II - Laboratory Course Lab 4: Common GUI Event Types and Listener Interfaces Layout Mangers Faculty of Engineering.
UID – Event Handling and Listeners Boriana Koleva
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
Object Oriented Programming.  Interface  Event Handling.
Agenda Introduction. Event Model. Creating GUI Application. Event Examples.
Creating User Interfaces Event-Driven Programming.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 15 Event-Driven Programming and.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 15 Event-Driven Programming and.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Events (Chapter 11) Java Certification Study Group January 25, 1999 Mark Roth.
1 Chapter 3 Event-Driven Programming. 2 Objectives F To explain the concept of event-driven programming (§12.2). F To understand event, event source,
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Jozef Goetz Credits: Copyright  Pearson Education, Inc. All rights reserved. expanded by J. Goetz, 2016.
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
© Copyright by Pearson Education, Inc. All Rights Reserved. Appendix I GUI Components and Event Handling Android How to Program, 3/e.
GUI Programming using Java - Event Handling
CSC 205 Programming II Lecture 5 AWT - I.
Events and Event Handling
Chapter 14 Event-Driven Programming
CompSci 230 S Programming Techniques
Chapter 15 Event-Driven Programming and Animations
CompSci 230 S Software Construction
CHAPTER Reacting to the user.
Chapter 12 Event-Driven Programming
Web Design & Development Lecture 11
Appendix I GUI Components and Event Handling
Responding to Events Event Handling in Java
A First Look at GUI Applications
Introduction to Event-Driven Programming
Chapter Topics 15.1 Graphical User Interfaces
Event loops 16-Jun-18.
Chapter Eleven Handling Events.
Java Programming: From Problem Analysis to Program Design,
Lecture 28 Concurrent, Responsive GUIs
Introduction to Events
Programming in Java Event Handling
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Event-driven programming for GUI
Event Driven Programming
Event Driven Programming and Graphical User Interface
Event loops.
1/10/2019 JavaFX Events COSC 330.
Chapter 16 Event-Driven Programming
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Events, Event Handlers, and Threads
Event loops 8-Apr-19.
Tonga Institute of Higher Education
Chapter 15 Event-Driven Programming and Animations Part 1
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Event Driven Systems and Modeling B. Ramamurthy 1/12/2019 BR

Topics Simple Event cycle Custom events Event driven systems Source, target, activation, dispatch, listener, handler Example: SimpleExample.java that comes JDK distribution. Custom events Event driven systems 1/12/2019 BR

Types of Programs Control-driven: The order in the program code determines the sequence of events. The actions are predetermined. Event-driven: The operation of the program depends on what you do with the controls presented (usually by the GUI) Selecting menu items, pressing buttons, dialog interaction cause actions within the program. Events in dynamic system/asynchronous systems. 1/12/2019 BR

Events 1. Actions such as clicking a button, moving a mouse, are recognized and identified by the operating systems(OS) or JVM. 2. For each action, OS/JVM determines which of the many currently running programs should receive the signal (of the action) 3. The signals that the application receives from the OS/JVM as result of the actions are called events. 1/12/2019 BR

Event Generation User Interface Mouse actions, keystrokes, events Operating Systems JAVA API /Windows Events Methods and handlers Methods and handlers Application 1 Application 2 1/12/2019 BR

Event Handlers An application responds to the events by executing particular code meant for each type of event. Not all events need to be handled by an application. For example, a drawing application may be interested in handling only mouse movements. As a designer of an event-driven application you will write classes/methods to handle the relevant events. 1/12/2019 BR

Event Handling Process Source of an event is modeled as an object. Ex: button click’s object is a button Type of the event: ActionEvent, WindowEvent, MouseEvent etc. Ex: An ActionEvent object is passed to the application that contains information about the action. Target of an event: Listener object of the event. Passing the event to a listener results in calling a particular method of the listener object. 1/12/2019 BR

Event Handling Three ways: Application/applet itself is a (mouse) listener, with an action performed method. Event handling delegated to an object specially instantiated for this purpose. Anonymous class/object to handle just one event. 1/12/2019 BR

Designing Custom Events Three elements to generate and listen to events: An event class An event listener interface An event generator 1/12/2019 BR

Event class Java provides two super classes to define event class: EventObject (for non-GUI events) AWTEvent (typically for GUI controls) EventObject has at least one method getSource that returns an Object at which the event occurred. For your custom event class you extend this class and add other methods needed. 1/12/2019 BR

Listener Interface The listener interface provides the contract between the listeners and the event generator. The contract provides the event generator with the method to call when it fires an event. When creating an event listener interface, you can add as many methods as you need. However, by convention, each method normally takes only one argument: the event. 1/12/2019 BR

Event Generator An event generator tracks listeners, provides a mechanism to add and remove listeners, and, at the appropriate time, fires events to the listeners. When creating an event generator, make sure its registration mechanism is thread safe. Generator receives the stimulus and dispatches the events. Lets look at Mr. Happy Object example. 1/12/2019 BR

Event: Mood Write the Mood class Write the MoodEvent class that extends EventObject Write MoodListener that has one method MoodReceived Mr.HappyObject will allow registration of listeners (add and remove listeners) and receive stimulus of pinch and hug and dispatch them appropriately. Listener classes (Sky and FlockOfBirds) implement MoodListener interface. These listeners are added to HappyObject by the application. They keep listening to HappyObject mood change and take appropriate action. 1/12/2019 BR

UML diagram 1/12/2019 BR

Summary Apply the concept studied to an event driven system. Design events, event object classes, listener interfaces, event generators-registrars and dispatchers. And an application connecting all these. 1/12/2019 BR