img
The class AWTEvent, defined within the java.awt package, is a subclass of EventObject.
It is the superclass (either directly or indirectly) of all AWT-based events used by the delegation
event model. Its getID( ) method can be used to determine the type of the event. The signature
of this method is shown here:
int getID( )
Additional details about AWTEvent are provided at the end of Chapter 24. At this point, it
is important to know only that all of the other classes discussed in this section are subclasses
of AWTEvent.
To summarize:
· EventObject is a superclass of all events.
· AWTEvent is a superclass of all AWT events that are handled by the delegation
event model.
The package java.awt.event defines many types of events that are generated by various
user interface elements. Table 22-1 shows several commonly used event classes and provides
a brief description of when they are generated. Commonly used constructors and methods in
each class are described in the following sections.
The ActionEvent Class
An ActionEvent is generated when a button is pressed, a list item is double-clicked, or a
menu item is selected. The ActionEvent class defines four integer constants that can be
used to identify any modifiers associated with an action event: ALT_MASK, CTRL_MASK,
META_MASK, and SHIFT_MASK. In addition, there is an integer constant, ACTION_
PERFORMED, which can be used to identify action events.
Event Class
Description
ActionEvent
Generated when a button is pressed, a list item is double-clicked, or a menu
item is selected.
AdjustmentEvent
Generated when a scroll bar is manipulated.
ComponentEvent
Generated when a component is hidden, moved, resized, or becomes visible.
ContainerEvent
Generated when a component is added to or removed from a container.
FocusEvent
Generated when a component gains or loses keyboard focus.
InputEvent
Abstract superclass for all component input event classes.
ItemEvent
Generated when a check box or list item is clicked; also occurs when a choice
selection is made or a checkable menu item is selected or deselected.
KeyEvent
Generated when input is received from the keyboard.
MouseEvent
Generated when the mouse is dragged, moved, clicked, pressed, or released;
also generated when the mouse enters or exits a component.
MouseWheelEvent
Generated when the mouse wheel is moved.
TextEvent
Generated when the value of a text area or text field is changed.
WindowEvent
Generated when a window is activated, closed, deactivated, deiconified,
iconified, opened, or quit.
TABLE 22-1
Main Event Classes in java.awt.event
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home