img
ActionEvent has these three constructors:
ActionEvent(Object src, int type, String cmd)
ActionEvent(Object src, int type, String cmd, int modifiers)
ActionEvent(Object src, int type, String cmd, long when, int modifiers)
Here, src is a reference to the object that generated this event. The type of the event is specified
by type, and its command string is cmd. The argument modifiers indicates which modifier keys
(ALT, CTRL, META, and/or SHIFT) were pressed when the event was generated. The when
parameter specifies when the event occurred.
You can obtain the command name for the invoking ActionEvent object by using the
getActionCommand( ) method, shown here:
String getActionCommand( )
For example, when a button is pressed, an action event is generated that has a command
name equal to the label on that button.
The getModifiers( ) method returns a value that indicates which modifier keys (ALT, CTRL,
META, and/or SHIFT) were pressed when the event was generated. Its form is shown here:
int getModifiers( )
The method getWhen( ) returns the time at which the event took place. This is called the
event's timestamp. The getWhen( ) method is shown here:
long getWhen( )
The AdjustmentEvent Class
An AdjustmentEvent is generated by a scroll bar. There are five types of adjustment events.
The AdjustmentEvent class defines integer constants that can be used to identify them. The
constants and their meanings are shown here:
BLOCK_DECREMENT
The user clicked inside the scroll bar to decrease its value.
BLOCK_INCREMENT
The user clicked inside the scroll bar to increase its value.
TRACK
The slider was dragged.
UNIT_DECREMENT
The button at the end of the scroll bar was clicked to decrease its value.
UNIT_INCREMENT
The button at the end of the scroll bar was clicked to increase its value.
In addition, there is an integer constant, ADJUSTMENT_VALUE_CHANGED, that
indicates that a change has occurred.
Here is one AdjustmentEvent constructor:
AdjustmentEvent(Adjustable src, int id, int type, int data)
Here, src is a reference to the object that generated this event. The id specifies the event. The
type of the adjustment is specified by type, and its associated data is data.
The getAdjustable( ) method returns the object that generated the event. Its form is
shown here:
Adjustable getAdjustable( )
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home