PPT06_Event_Model - Javas Event Model The Event Model Event...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Java’s Event Model The Event Model Event GUI operating environments monitor user actions. When the user performs an action on a GUI component it is called an event. Events generally correspond with actions such as: mouse button click typing a key moving a mouse Example of an Observer design pattern Event source (GUI Component) An object that generates an event Maintains a list of listeners Provides methods for adding and removing a listener from the list Event Object An object encapsulating the information about a specific event. It is passed to an event listener so that the listener can process the event. Listener An object that provides processing for an event. Implements a Listener Interface Listener Interface Included in java.awt.event package A listener class is an interface class used to respond to an event. When an event occurs: The event source sends Event objects to all registered event listeners The listener method is invoked with the Event object passed as the argument. In order to handle the event, listeners must override the required methods Event Class Listener Interface Listener Methods ActionEvent ActionListener actionPerformed( ) AdjustmentEvent AdjustmentListener adjustmentValueChanged( ) ComponentEvent ComponentListener componentHidden( ) componentMoved( ) componentResized( ) componentShown( ) ContainerEvent ContainerListener componentAdded( ) componentRemoved( ) FocusEvent FocusListener focusGained( ) focusLost( ) ItemEvent ItemListener itemStateChanged( ) KeyEvent
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

PPT06_Event_Model - Javas Event Model The Event Model Event...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online