Overview
Package
Class
Use
Tree
Deprecated
Index
All Classes
Help
Prev Class
Next Class
Sample
Document
Class java.awt.event.ActionEvent
Inherited members: ShowHide
Deprecated: ShowHide
View: ClientSubclassPackageImplementation
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 AWTEvent
    A semantic event which indicates that a component-defined action occurred. This high-level event is generated by a component (such as a Button) when the component-specific action occurs (such as being pressed). The event is passed to every ActionListener object that registered to receive such events using the component's addActionListener method.

    Note: To invoke an ActionEvent on a Button using the keyboard, use the Space bar.

    The object that implements the ActionListener interface gets this ActionEvent 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 particular ActionEvent instance is not in the range from ACTION_FIRST to ACTION_LAST.

    Since:
    1.1
    See Also:
    ActionListener, Tutorial: How to Write an Action Listener, Serialized Form
    • Fields 
      Modifier and Type Field and Description
      Inherited member indicator ACTION_EVENT_MASK Reveal DetailHide Detail
      static long ACTION_EVENT_MASK
      The event mask for selecting action events.
      public static final long ACTION_EVENT_MASK
      The event mask for selecting action events.
      See Also:
      Constant Field Values
      Ordinary member indicator ACTION_FIRST Reveal DetailHide Detail
      static int ACTION_FIRST
      The first number in the range of ids used for action events.
      public static final int ACTION_FIRST
      The first number in the range of ids used for action events.
      See Also:
      Constant Field Values
      Ordinary member indicator ACTION_LAST Reveal DetailHide Detail
      static int ACTION_LAST
      The last number in the range of ids used for action events.
      public static final int ACTION_LAST
      The last number in the range of ids used for action events.
      See Also:
      Constant Field Values
      Ordinary member indicator ACTION_PERFORMED Reveal DetailHide Detail
      static int ACTION_PERFORMED
      This event id indicates that a meaningful action occured.
      public static final int ACTION_PERFORMED
      This event id indicates that a meaningful action occured.
      See Also:
      Constant Field Values
      Inherited member indicator ADJUSTMENT_EVENT_MASK Reveal DetailHide Detail
      static long ADJUSTMENT_EVENT_MASK
      The event mask for selecting adjustment events.
      public static final long ADJUSTMENT_EVENT_MASK
      The event mask for selecting adjustment events.
      See Also:
      Constant Field Values
      Ordinary member indicator ALT_MASK Reveal DetailHide Detail
      static int ALT_MASK
      The alt modifier.
      public static final int ALT_MASK
      The alt modifier. An indicator that the alt key was held down during the event.
      See Also:
      Constant Field Values
      Inherited member indicator COMPONENT_EVENT_MASK Reveal DetailHide Detail
      static long COMPONENT_EVENT_MASK
      The event mask for selecting component events.
      public static final long COMPONENT_EVENT_MASK
      The event mask for selecting component events.
      See Also:
      Constant Field Values
      Inherited member indicator consumed Reveal DetailHide Detail
      protected boolean 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.
      protected boolean 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. Semantic events always have a 'true' value since they were generated by the peer in response to a low-level event.
      See Also:
      AWTEvent.consume(), AWTEvent.isConsumed()
      Inherited member indicator CONTAINER_EVENT_MASK Reveal DetailHide Detail
      static long CONTAINER_EVENT_MASK
      The event mask for selecting container events.
      public static final long CONTAINER_EVENT_MASK
      The event mask for selecting container events.
      See Also:
      Constant Field Values
      Ordinary member indicator CTRL_MASK Reveal DetailHide Detail
      static int CTRL_MASK
      The control modifier.
      public static final int CTRL_MASK
      The control modifier. An indicator that the control key was held down during the event.
      See Also:
      Constant Field Values
      Inherited member indicator FOCUS_EVENT_MASK Reveal DetailHide Detail
      static long FOCUS_EVENT_MASK
      The event mask for selecting focus events.
      public static final long FOCUS_EVENT_MASK
      The event mask for selecting focus events.
      See Also:
      Constant Field Values
      Inherited member indicator HIERARCHY_BOUNDS_EVENT_MASK Reveal DetailHide Detail
      static long HIERARCHY_BOUNDS_EVENT_MASK
      The event mask for selecting hierarchy bounds events.
      public static final long HIERARCHY_BOUNDS_EVENT_MASK
      The event mask for selecting hierarchy bounds events.
      See Also:
      Constant Field Values
      Inherited member indicator HIERARCHY_EVENT_MASK Reveal DetailHide Detail
      static long HIERARCHY_EVENT_MASK
      The event mask for selecting hierarchy events.
      public static final long HIERARCHY_EVENT_MASK
      The event mask for selecting hierarchy events.
      See Also:
      Constant Field Values
      Inherited member indicator id Reveal DetailHide Detail
      protected int id
      The event's id.
      protected int id
      The event's id.
      See Also:
      AWTEvent.getID(), AWTEvent.AWTEvent(java.lang.Object, int)
      Inherited member indicator INPUT_METHOD_EVENT_MASK Reveal DetailHide Detail
      static long INPUT_METHOD_EVENT_MASK
      The event mask for selecting input method events.
      public static final long INPUT_METHOD_EVENT_MASK
      The event mask for selecting input method events.
      See Also:
      Constant Field Values
      Inherited member indicator INVOCATION_EVENT_MASK Reveal DetailHide Detail
      static long INVOCATION_EVENT_MASK
      The event mask for selecting invocation events.
      public static final long INVOCATION_EVENT_MASK
      The event mask for selecting invocation events.
      See Also:
      Constant Field Values
      Inherited member indicator ITEM_EVENT_MASK Reveal DetailHide Detail
      static long ITEM_EVENT_MASK
      The event mask for selecting item events.
      public static final long ITEM_EVENT_MASK
      The event mask for selecting item events.
      See Also:
      Constant Field Values
      Inherited member indicator KEY_EVENT_MASK Reveal DetailHide Detail
      static long KEY_EVENT_MASK
      The event mask for selecting key events.
      public static final long KEY_EVENT_MASK
      The event mask for selecting key events.
      See Also:
      Constant Field Values
      Ordinary member indicator META_MASK Reveal DetailHide Detail
      static int META_MASK
      The meta modifier.
      public static final int META_MASK
      The meta modifier. An indicator that the meta key was held down during the event.
      See Also:
      Constant Field Values
      Inherited member indicator MOUSE_EVENT_MASK Reveal DetailHide Detail
      static long MOUSE_EVENT_MASK
      The event mask for selecting mouse events.
      public static final long MOUSE_EVENT_MASK
      The event mask for selecting mouse events.
      See Also:
      Constant Field Values
      Inherited member indicator MOUSE_MOTION_EVENT_MASK Reveal DetailHide Detail
      static long MOUSE_MOTION_EVENT_MASK
      The event mask for selecting mouse motion events.
      public static final long MOUSE_MOTION_EVENT_MASK
      The event mask for selecting mouse motion events.
      See Also:
      Constant Field Values
      Inherited member indicator MOUSE_WHEEL_EVENT_MASK Reveal DetailHide Detail
      static long MOUSE_WHEEL_EVENT_MASK
      The event mask for selecting mouse wheel events.
      public static final long MOUSE_WHEEL_EVENT_MASK
      The event mask for selecting mouse wheel events.
      Since:
      1.4
      See Also:
      Constant Field Values
      Inherited member indicator PAINT_EVENT_MASK Reveal DetailHide Detail
      static long PAINT_EVENT_MASK
      The event mask for selecting paint events.
      public static final long PAINT_EVENT_MASK
      The event mask for selecting paint events.
      See Also:
      Constant Field Values
      Inherited member indicator RESERVED_ID_MAX Reveal DetailHide Detail
      static int RESERVED_ID_MAX
      The maximum value for reserved AWT event IDs.
      public static final int RESERVED_ID_MAX
      The maximum value for reserved AWT event IDs. Programs defining their own event IDs should use IDs greater than this value.
      See Also:
      Constant Field Values
      Ordinary member indicator SHIFT_MASK Reveal DetailHide Detail
      static int SHIFT_MASK
      The shift modifier.
      public static final int SHIFT_MASK
      The shift modifier. An indicator that the shift key was held down during the event.
      See Also:
      Constant Field Values
      Inherited member indicator source Reveal DetailHide Detail
      protected java.lang.Object source
      The object on which the Event initially occurred.
      protected transient java.lang.Object source
      The object on which the Event initially occurred.
      Inherited member indicator TEXT_EVENT_MASK Reveal DetailHide Detail
      static long TEXT_EVENT_MASK
      The event mask for selecting text events.
      public static final long TEXT_EVENT_MASK
      The event mask for selecting text events.
      See Also:
      Constant Field Values
      Inherited member indicator WINDOW_EVENT_MASK Reveal DetailHide Detail
      static long WINDOW_EVENT_MASK
      The event mask for selecting window events.
      public static final long WINDOW_EVENT_MASK
      The event mask for selecting window events.
      See Also:
      Constant Field Values
      Inherited member indicator WINDOW_FOCUS_EVENT_MASK Reveal DetailHide Detail
      static long WINDOW_FOCUS_EVENT_MASK
      The event mask for selecting window focus events.
      public static final long WINDOW_FOCUS_EVENT_MASK
      The event mask for selecting window focus events.
      Since:
      1.4
      See Also:
      Constant Field Values
      Inherited member indicator WINDOW_STATE_EVENT_MASK Reveal DetailHide Detail
      static long WINDOW_STATE_EVENT_MASK
      The event mask for selecting window state events.
      public static final long WINDOW_STATE_EVENT_MASK
      The event mask for selecting window state events.
      Since:
      1.4
      See Also:
      Constant Field Values
    • Constructors 
      Constructor and Description
      Ordinary member indicator ActionEvent Reveal DetailHide Detail
      ActionEvent(java.lang.Object source, int id, java.lang.String command)
      Constructs an ActionEvent object.
      public ActionEvent(java.lang.Object source, int id, java.lang.String command)
      Constructs an ActionEvent object.

      This method throws an IllegalArgumentException if source is null. A null command string is legal, but not recommended.

      Parameters:
      source - The object that originated the event
      id - An integer that identifies the event. For information on allowable values, see the class description for ActionEvent
      command - A string that may specify a command (possibly one of several) associated with the event
      Throws:
      java.lang.IllegalArgumentException - if source is null
      See Also:
      EventObject.getSource(), AWTEvent.getID(), getActionCommand()
      Ordinary member indicator ActionEvent Reveal DetailHide Detail
      ActionEvent(java.lang.Object source, int id, java.lang.String command, int modifiers)
      Constructs an ActionEvent object with modifier keys.
      public ActionEvent(java.lang.Object source, int id, java.lang.String command, int modifiers)
      Constructs an ActionEvent object with modifier keys.

      This method throws an IllegalArgumentException if source is null. A null command string is legal, but not recommended.

      Parameters:
      source - The object that originated the event
      id - An integer that identifies the event. For information on allowable values, see the class description for ActionEvent
      command - A string that may specify a command (possibly one of several) associated with the event
      modifiers - The modifier keys down during event (shift, ctrl, alt, meta). Passing negative parameter is not recommended. Zero value means that no modifiers were passed
      Throws:
      java.lang.IllegalArgumentException - if source is null
      See Also:
      EventObject.getSource(), AWTEvent.getID(), getActionCommand(), getModifiers()
      Ordinary member indicator ActionEvent Reveal DetailHide Detail
      ActionEvent(java.lang.Object source, int id, java.lang.String command, long when, int modifiers)
      Constructs an ActionEvent object with the specified modifier keys and timestamp.
      public ActionEvent(java.lang.Object source, int id, java.lang.String command, long when, int modifiers)
      Constructs an ActionEvent object with the specified modifier keys and timestamp.

      This method throws an IllegalArgumentException if source is null. A null command string is legal, but not recommended.

      Parameters:
      source - The object that originated the event
      id - An integer that identifies the event. For information on allowable values, see the class description for ActionEvent
      command - A string that may specify a command (possibly one of several) associated with the event
      modifiers - The modifier keys down during event (shift, ctrl, alt, meta). Passing negative parameter is not recommended. Zero value means that no modifiers were passed
      when - A long that gives the time the event occurred. Passing negative or zero value is not recommended
      Throws:
      java.lang.IllegalArgumentException - if source is null
      Since:
      1.4
      See Also:
      EventObject.getSource(), AWTEvent.getID(), getActionCommand(), getModifiers(), getWhen()
    • Methods 
      Modifier and Type Method and Description
      Inherited member indicator consume Reveal DetailHide Detail
      protected void consume()
      Consumes this event, if this event can be consumed.
      protected void consume()
      Description copied from class: AWTEvent
      Consumes this event, if this event can be consumed. Only low-level, system events can be consumed
      Ordinary member indicator getActionCommand Reveal DetailHide Detail
      java.lang.String getActionCommand()
      Returns the command string associated with this action.
      public java.lang.String getActionCommand()
      Returns the command string associated with this action. This string allows a "modal" component to specify one of several commands, depending on its state. For example, a single button might toggle between "show details" and "hide details". The source object and the event would be the same in each case, but the command string would identify the intended action.

      Note that if a null command string was passed to the constructor for this ActionEvent, this this method returns null.

      Returns:
      the string identifying the command for this event
      Inherited member indicator getID Reveal DetailHide Detail
      int getID()
      Returns the event type.
      public int getID()
      Description copied from class: AWTEvent
      Returns the event type.
      Ordinary member indicator getModifiers Reveal DetailHide Detail
      int getModifiers()
      Returns the modifier keys held down during this action event.
      public int getModifiers()
      Returns the modifier keys held down during this action event.
      Returns:
      the bitwise-or of the modifier constants
      Inherited member indicator getSource Reveal DetailHide Detail
      java.lang.Object getSource()
      The object on which the Event initially occurred.
      public java.lang.Object getSource()
      Description copied from class: java.util.EventObject
      The object on which the Event initially occurred.
      Returns:
      The object on which the Event initially occurred.
      Ordinary member indicator getWhen Reveal DetailHide Detail
      long getWhen()
      Returns the timestamp of when this event occurred.
      public long getWhen()
      Returns the timestamp of when this event occurred. Because an ActionEvent is a high-level, semantic event, the timestamp is typically the same as an underlying InputEvent.
      Returns:
      this event's timestamp
      Since:
      1.4
      Inherited member indicator isConsumed Reveal DetailHide Detail
      protected boolean isConsumed()
      Returns whether this event has been consumed.
      protected boolean isConsumed()
      Description copied from class: AWTEvent
      Returns whether this event has been consumed.
      Overridden member indicator paramString Reveal DetailHide Detail
      java.lang.String paramString()
      Returns a parameter string identifying this action event.
      public java.lang.String paramString()
      Returns a parameter string identifying this action event. This method is useful for event-logging and for debugging.
      Overrides:
      paramString in class AWTEvent
      Returns:
      a string identifying the event and its associated command
      Inherited member indicator setSource Reveal DetailHide Detail
      void setSource(java.lang.Object newSource)
      Retargets an event to a new source.
      public void setSource(java.lang.Object newSource)
      Description copied from class: AWTEvent
      Retargets an event to a new source. This method is typically used to retarget an event to a lightweight child Component of the original heavyweight source.

      This method is intended to be used only by event targeting subsystems, such as client-defined KeyboardFocusManagers. It is not for general client use.

      Parameters:
      newSource - the new Object to which the event should be dispatched
      Since:
      1.4
      Inherited member indicator toString Reveal DetailHide Detail
      java.lang.String toString()
      Returns a String representation of this object.
      public java.lang.String toString()
      Description copied from class: AWTEvent
      Returns a String representation of this object.
      Overrides:
      toString in class java.util.EventObject
      Returns:
      A a String representation of this EventObject.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
This document was created by Dulcet from the OpenJDK sources. Copyright © 1993, 2012 Oracle and/or its affiliates. All rights reserved.

SourceForge