img
WindowEvent is a subclass of ComponentEvent. It defines several constructors. The
first is
WindowEvent(Window src, int type)
Here, src is a reference to the object that generated this event. The type of the event is type.
The next three constructors offer more detailed control:
WindowEvent(Window src, int type, Window other)
WindowEvent(Window src, int type, int fromState, int toState)
WindowEvent(Window src, int type, Window other, int fromState, int toState)
Here, other specifies the opposite window when a focus or activation event occurs. The
fromState specifies the prior state of the window, and toState specifies the new state that the
window will have when a window state change occurs.
A commonly used method in this class is getWindow( ). It returns the Window object
that generated the event. Its general form is shown here:
Window getWindow( )
WindowEvent also defines methods that return the opposite window (when a focus or
activation event has occurred), the previous window state, and the current window state.
These methods are shown here:
Window getOppositeWindow( )
int getOldState( )
int getNewState( )
Sources of Events
Table 22-2 lists some of the user interface components that can generate the events described
in the previous section. In addition to these graphical user interface elements, any class derived
Event Source
Description
Button
Generates action events when the button is pressed.
Check box
Generates item events when the check box is selected or deselected.
Choice
Generates item events when the choice is changed.
List
Generates action events when an item is double-clicked; generates item
events when an item is selected or deselected.
Menu Item
Generates action events when a menu item is selected; generates item
events when a checkable menu item is selected or deselected.
Scroll bar
Generates adjustment events when the scroll bar is manipulated.
Text components
Generates text events when the user enters a character.
Window
Generates window events when a window is activated, closed, deactivated,
deiconified, iconified, opened, or quit.
TABLE 22-2
Event Source Examples
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home