Java Reference
In-Depth Information
AWT and Swing components. Additional event types that are specific to Swing GUI com-
ponents are declared in package javax.swing.event .
Object
ActionEvent
AdjustmentEvent
EventObject
ContainerEvent
ItemEvent
AWTEvent
FocusEvent
TextEvent
PaintEvent
ComponentEvent
WindowEvent
InputEvent
KeyEvent
MouseEvent
MouseWheelEvent
Fig. 12.11 | Some event classes of package java.awt.event .
Let's summarize the three parts to the event-handling mechanism that you saw in
Section 12.6—the event source , the event object and the event listener . The event source is
the GUI component with which the user interacts. The event object encapsulates infor-
mation about the event that occurred, such as a reference to the event source and any
event-specific information that may be required by the event listener for it to handle the
event. The event listener is an object that's notified by the event source when an event
occurs; in effect, it “listens” for an event, and one of its methods executes in response to
the event. A method of the event listener receives an event object when the event listener
is notified of the event. The event listener then uses the event object to respond to the
event. This event-handling model is known as the delegation event model —an event's
processing is delegated to an object (the event listener) in the application.
For each event-object type, there's typically a corresponding event-listener interface.
An event listener for a GUI event is an object of a class that implements one or more of
the event-listener interfaces from packages java.awt.event and javax.swing.event .
Many of the event-listener types are common to both Swing and AWT components. Such
types are declared in package java.awt.event , and some of them are shown in Fig. 12.12.
Additional event-listener types that are specific to Swing components are declared in
package javax.swing.event .
 
 
Search WWH ::




Custom Search