java.awt.event

Class ActionEvent

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, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, 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, consumed, id

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, paramString, setSource, toString

Methods inherited from class java.util.EventObject

getSource, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

ACTION_FIRST

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

ACTION_LAST

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

ACTION_PERFORMED

public static final int ACTION_PERFORMED
An event id indicating that an action has occurred.
Field Value:
1001

ALT_MASK

public static final int ALT_MASK
Bit mask indicating that the alt key was pressed.
Field Value:
8

CTRL_MASK

public static final int CTRL_MASK
Bit mask indicating the control key was pressed.
Field Value:
2

META_MASK

public static final int META_MASK
Bit mask indicating the that meta key was pressed.
Field Value:
4

SHIFT_MASK

public static final int SHIFT_MASK
Bit mask indicating the shift key was pressed.
Field Value:
1

Constructor Details

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 Details

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().
Overrides:
paramString in interface AWTEvent
Returns:
a string identifying the event

ActionEvent.java -- an action has been triggered Copyright (C) 1999, 2002, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.