java.awt.event

Class ActionEvent

public class ActionEvent extends AWTEvent

This event is generated when an action on a component (such as a button press) occurs.

Since: 1.1

See Also: ActionListener

UNKNOWN: updated to 1.4

Field Summary
static intACTION_FIRST
The first id number in the range of action id's.
static intACTION_LAST
The last id number in the range of action id's.
static intACTION_PERFORMED
An event id indicating that an action has occurred.
static intALT_MASK
Bit mask indicating that the alt key was pressed.
static intCTRL_MASK
Bit mask indicating the control key was pressed.
static intMETA_MASK
Bit mask indicating the that meta key was pressed.
static intSHIFT_MASK
Bit mask indicating the shift key was pressed.
Constructor Summary
ActionEvent(Object source, int id, String command)
Initializes a new instance of ActionEvent with the specified source, id, and command.
ActionEvent(Object source, int id, String command, int modifiers)
Initializes a new instance of ActionEvent with the specified source, id, command, and modifiers.
ActionEvent(Object source, int id, String command, long when, int modifiers)
Initializes a new instance of ActionEvent with the specified source, id, command, and modifiers, and timestamp.
Method Summary
StringgetActionCommand()
Returns the command string associated with this action.
intgetModifiers()
Returns the keys held down during the action.
longgetWhen()
Gets the timestamp of when this action took place.
StringparamString()
Returns a string that identifies the action event.

Field Detail

ACTION_FIRST

public static final int ACTION_FIRST
The first id number in the range of action id's.

ACTION_LAST

public static final int ACTION_LAST
The last id number in the range of action id's.

ACTION_PERFORMED

public static final int ACTION_PERFORMED
An event id indicating that an action has occurred.

ALT_MASK

public static final int ALT_MASK
Bit mask indicating that the alt key was pressed.

CTRL_MASK

public static final int CTRL_MASK
Bit mask indicating the control key was pressed.

META_MASK

public static final int META_MASK
Bit mask indicating the that meta key was pressed.

SHIFT_MASK

public static final int SHIFT_MASK
Bit mask indicating the shift key was pressed.

Constructor Detail

ActionEvent

public ActionEvent(Object source, int id, String command)
Initializes a new instance of ActionEvent with the specified source, id, and command. Note that an invalid id leads to unspecified results.

Parameters: source the event source id the event id command the command string for this action

Throws: IllegalArgumentException if source is null

ActionEvent

public ActionEvent(Object source, int id, String command, int modifiers)
Initializes a new instance of ActionEvent with the specified source, id, command, and modifiers. Note that an invalid id leads to unspecified results.

Parameters: source the event source id the event id command the command string for this action modifiers the bitwise or of modifier keys down during the action

Throws: IllegalArgumentException if source is null

ActionEvent

public ActionEvent(Object source, int id, String command, long when, int modifiers)
Initializes a new instance of ActionEvent with the specified source, id, command, and modifiers, and timestamp. Note that an invalid id leads to unspecified results.

Parameters: source the event source id the event id command the command string for this action when the timestamp of the event modifiers the bitwise or of modifier keys down during the action

Throws: IllegalArgumentException if source is null

Since: 1.4

Method Detail

getActionCommand

public String getActionCommand()
Returns the command string associated with this action.

Returns: the command string associated with this action

getModifiers

public int getModifiers()
Returns the keys held down during the action. This value will be a combination of the bit mask constants defined in this class, or 0 if no modifiers were pressed.

Returns: the modifier bits

getWhen

public long getWhen()
Gets the timestamp of when this action took place. Usually, this corresponds to the timestamp of the underlying InputEvent.

Returns: the timestamp of this action

Since: 1.4

paramString

public String paramString()
Returns a string that identifies the action event. This is in the format "ACTION_PERFORMED,cmd=" + getActionCommand() + ",when=" + getWhen() + ",modifiers=" + <modifier string>, where the modifier string is in the order "Meta", "Ctrl", "Alt", "Shift", "Alt Graph", and "Button1", separated by '+', according to the bits set in getModifiers().

Returns: a string identifying the event