java.awt.event
Class ActionEvent
- java.lang.Object
-
- java.util.EventObject
-
- java.awt.AWTEvent
-
- java.awt.event.ActionEvent
-
- All Implemented Interfaces:
- java.io.Serializable
public class ActionEvent extends AWTEventA semantic event which indicates that a component-defined action occurred. This high-level event is generated by a component (such as aButton
) when the component-specific action occurs (such as being pressed). The event is passed to everyActionListener
object that registered to receive such events using the component'saddActionListener
method.Note: To invoke an
ActionEvent
on aButton
using the keyboard, use the Space bar.The object that implements the
ActionListener
interface gets thisActionEvent
when the event occurs. The listener is therefore spared the details of processing individual mouse movements and mouse clicks, and can instead process a "meaningful" (semantic) event like "button pressed".An unspecified behavior will be caused if the
id
parameter of any particularActionEvent
instance is not in the range fromACTION_FIRST
toACTION_LAST
.- Since:
- 1.1
- See Also:
ActionListener
, Tutorial: How to Write an Action Listener, Serialized Form
-
-
Fields Modifier and Type Field and Description ACTION_EVENT_MASK The event mask for selecting action events.ACTION_FIRST The first number in the range of ids used for action events.ACTION_LAST The last number in the range of ids used for action events.ACTION_PERFORMED This event id indicates that a meaningful action occured.ADJUSTMENT_EVENT_MASK The event mask for selecting adjustment events.ALT_MASK The alt modifier.COMPONENT_EVENT_MASK The event mask for selecting component events.consumed Controls whether or not the event is sent back down to the peer once the source has processed it - false means it's sent to the peer; true means it's not.CONTAINER_EVENT_MASK The event mask for selecting container events.CTRL_MASK The control modifier.FOCUS_EVENT_MASK The event mask for selecting focus events.HIERARCHY_BOUNDS_EVENT_MASK The event mask for selecting hierarchy bounds events.HIERARCHY_EVENT_MASK The event mask for selecting hierarchy events.id The event's id.INPUT_METHOD_EVENT_MASK The event mask for selecting input method events.INVOCATION_EVENT_MASK The event mask for selecting invocation events.ITEM_EVENT_MASK The event mask for selecting item events.KEY_EVENT_MASK The event mask for selecting key events.META_MASK The meta modifier.MOUSE_EVENT_MASK The event mask for selecting mouse events.MOUSE_MOTION_EVENT_MASK The event mask for selecting mouse motion events.MOUSE_WHEEL_EVENT_MASK The event mask for selecting mouse wheel events.PAINT_EVENT_MASK The event mask for selecting paint events.RESERVED_ID_MAX The maximum value for reserved AWT event IDs.SHIFT_MASK The shift modifier.source The object on which the Event initially occurred.TEXT_EVENT_MASK The event mask for selecting text events.WINDOW_EVENT_MASK The event mask for selecting window events.WINDOW_FOCUS_EVENT_MASK The event mask for selecting window focus events.WINDOW_STATE_EVENT_MASK The event mask for selecting window state events.
-
Methods Modifier and Type Method and Description consume Consumes this event, if this event can be consumed.getActionCommand Returns the command string associated with this action.getID Returns the event type.getModifiers Returns the modifier keys held down during this action event.getSource The object on which the Event initially occurred.getWhen Returns the timestamp of when this event occurred.isConsumed Returns whether this event has been consumed.paramString Returns a parameter string identifying this action event.setSource Retargets an event to a new source.toString Returns a String representation of this object.
-