WindowEvent is a subclass of ComponentEvent. It defines several constructors. The
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
Generates action events when the button is pressed.
Generates item events when the check box is selected or deselected.
Generates item events when the choice is changed.
Generates action events when an item is double-clicked; generates item
events when an item is selected or deselected.
Generates action events when a menu item is selected; generates item
events when a checkable menu item is selected or deselected.
Generates adjustment events when the scroll bar is manipulated.
Generates text events when the user enters a character.
Generates window events when a window is activated, closed, deactivated,
deiconified, iconified, opened, or quit.
Event Source Examples
Search WWH :