80 likes | 238 Views
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 10. TOPICS TO COVER. Handling Events Interaction of user with GUI components is called event . Java events are part of the Java AWT package . The code that performs a task in response to an event is called an event handler.
E N D
TOPICS TO COVER Handling Events • Interaction of user with GUI components is called event. • Java events are part of the Java AWT package. • The code that performs a task in response to an event is called an event handler. • Overall process of responding to events is known as event handling. • GUIs are event driven. • The sourceof an event is the component that causes that event to occur. • The listenerof an event is an object that receives the event and processes it appropriately. Event Handling Process • When an event is triggered, the JAVA runtime first determines its source and type. • If a listener for this type of event is registered with the source, an event object is created. • For each listener to this type of an event, the JAVA runtime invokes the appropriate event handling method to the listener and passes the event object as the parameter.
Topics To Cover Sources of Events • Button • Checkbox • Choice • List • Menu Item • Scrollbar • Text Components • Window
An interface is a group of related methods with empty bodies. • Event classes and their listener interfaces are available in java.awt.event Event Handling
Event Handling • Event classes and their listener interfaces are available in java.awt.event
Assignment • Q#1: Display counting of mouse clicks on title bar of frame. • Q#2: Show a label of your name, move one step down as you click on frame.