java.awt.event
Class ActionEvent

java.lang.Object
  extended by java.util.EventObject
      extended by java.awt.AWTEvent
          extended by java.awt.event.ActionEvent
All Implemented Interfaces:
Serializable

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, Serialized Form

Field Summary
static int ACTION_FIRST
          The first id number in the range of action id's.
static int ACTION_LAST
          The last id number in the range of action id's.
static int ACTION_PERFORMED
          An event id indicating that an action has occurred.
static int ALT_MASK
          Bit mask indicating that the alt key was pressed.
static int CTRL_MASK
          Bit mask indicating the control key was pressed.
static int META_MASK
          Bit mask indicating the that meta key was pressed.
static int SHIFT_MASK
          Bit mask indicating the shift key was pressed.
 
Fields inherited from class java.awt.AWTEvent
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, MOUSE_WHEEL_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK, WINDOW_FOCUS_EVENT_MASK, WINDOW_STATE_EVENT_MASK
 
Fields inherited from class java.util.EventObject
source
 
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
 String getActionCommand()
          Returns the command string associated with this action.
 int getModifiers()
          Returns the keys held down during the action.
 long getWhen()
          Gets the timestamp of when this action took place.
 String paramString()
          Returns a string that identifies the action event.
 
Methods inherited from class java.awt.AWTEvent
consume, getID, isConsumed, setSource, toString
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SHIFT_MASK

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

See Also:
Constant Field Values

CTRL_MASK

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

See Also:
Constant Field Values

META_MASK

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

See Also:
Constant Field Values

ALT_MASK

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

See Also:
Constant Field Values

ACTION_FIRST

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

See Also:
Constant Field Values

ACTION_LAST

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

See Also:
Constant Field Values

ACTION_PERFORMED

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

See Also:
Constant Field Values
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

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

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

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().

Overrides:
paramString in class AWTEvent
Returns:
a string identifying the event