Responding to Events Event Handling in Java

Slides:



Advertisements
Similar presentations
Mari Göransson - KaU - Datavetenskap - DAVD11 1 Java Event Handling --
Advertisements

Event Handling.
Events and the AWT The objectives of this chapter are: To understand the principles of the Java 1.1 event model To understand how the event model is used.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
CS 178: Programming with Multimedia Objects Aditya P. Mathur Professor of Computer Sciences Purdue University, West Lafayette Sept 9, 2004 Last update:
Event Handling. In this class we will cover: Basics of event handling The AWT event hierarchy Semantic and low-level events in the AWT.
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,
More on Creating GUIs in Java using Swing David Meredith Aalborg University.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Dale Roberts GUI Programming using Java - Event Handling Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Computer Science [3] Java Programming II - Laboratory Course Lab 4: Common GUI Event Types and Listener Interfaces Layout Mangers Faculty of Engineering.
Event Handling. 2 GUIs are event driven –Generate events when user interacts with GUI e.g., moving mouse, pressing button, typing in text field, etc.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Object Oriented Programming.  Interface  Event Handling.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
Agenda Introduction. Event Model. Creating GUI Application. Event Examples.
GUI DYNAMICS Lecture 11 CS2110 – Fall GUI Statics and GUI Dynamics  Statics: what’s drawn on the screen  Components buttons, labels, lists, sliders,
Creating User Interfaces Chapter 13 CSCI CSCI 1302 – Creating User Interfaces2 Outline Introduction Common Features of Swing GUI Components Buttons.
Creating User Interfaces Event-Driven Programming.
Event-Driven Programming F Procedural programming is executed in procedural order. F In event-driven programming, code is executed upon activation of events.
Events (Chapter 11) Java Certification Study Group January 25, 1999 Mark Roth.
1 Event Handling – Lecture 4 Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI.
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,
CSI 3125, Preliminaries, page 1 Event Handling. CSI 3125, Preliminaries, page 2 Event Handling An Event Change in the state of an object is known as event.
1 Lecture 8: User Interface Components with Swing.
Jozef Goetz Credits: Copyright  Pearson Education, Inc. All rights reserved. expanded by J. Goetz, 2016.
Implement User Input Windows Development Fundamentals LESSON 2.4A.
GUI Programming using Java - Event Handling
CSC 205 Programming II Lecture 5 AWT - I.
Events and Event Handling
Chapter 14 Event-Driven Programming
Welcome To java
CompSci 230 S Programming Techniques
GUI Programming using Java - Key Events
Chapter 12 Event-Driven Programming
Keyboard Events keyboard acceleration TextFields
Aum Amriteshwaryai Namah
Web Design & Development Lecture 11
Java Events. Java Events Important definitions Overridden method Class vs. abstract class vs. interface Event Handling Definition Main components Windows.
Appendix I GUI Components and Event Handling
A First Look at GUI Applications
Advanced User Interfaces
Lecture 09 Applets.
Introduction to Event-Driven Programming
Chapter Topics 15.1 Graphical User Interfaces
Event-driven programming
Chapter 8: Writing Graphical User Interfaces
Lesson 1: Buttons and Events – 12/18
Programming in Java Event Handling
Ellen Walker Hiram College
Chap 7. Building Java Graphical User Interfaces
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
Event-driven programming for GUI
Event Driven Programming
Event loops.
Event Driven Programming
1/10/2019 JavaFX Events COSC 330.
Exception Handling and Event Handling
Chapter 15: GUI Applications & Event-Driven Programming
Tonga Institute of Higher Education
Chapter 13: Handling Events
Event loops.
ITEC220 GUI Lecture – Part 2 References
Presentation transcript:

Responding to Events Event Handling in Java Making the UI Work Responding to Events Event Handling in Java

Event Handling Event Handling Consist of the following 3 things Events Event Sources / Generators Event Listeners / Handlers 3/19/2008 11:06:58 PM Property of N++ Studios

Event An action which is recognized by an object is known as an Event For example. Moving the mouse pointer over button and clicking over the button Specific Event Listeners are available for handling specific events. 3/19/2008 11:06:58 PM Property of N++ Studios

Some Events, ActionEvent ItemEvent AdjustmentEvent KeyEvent Such as mouse clicks and Enter key presses ItemEvent Such as selecting an item from a dropdown list box AdjustmentEvent Such as moving a scrollbar KeyEvent Such as pressing a key on the Keyboard 3/19/2008 11:06:58 PM Property of N++ Studios

Event Sources / Generators Components which can generate the events are commonly known as event sources or event generators. Examples Button Scrollbar Checkbox Choice TextField 3/19/2008 11:06:58 PM Property of N++ Studios

Event Listeners / Handlers These are special kind of java Interfaces (type of java program) that is used to handle the events. Each Listener is built with one or more methods to respond to event, Before these Listeners can handle the events for you, you must register the components with the relevant Event Listener refer the code samples for more information. 3/19/2008 11:06:58 PM Property of N++ Studios

Question (s) Create an UI with two buttons, when you click on the first button the second button’s position should change. Create an UI to enter a number and display in a label EVEN or ODD with 2 different colors Create an UI with two TextFields and one button once you type something in the TextField and click the button count the number of characters in the 1st textfield and display it in the 2nd TextField. 3/19/2008 11:06:58 PM Property of N++ Studios