# Class AWTEvent

java.lang.Object
java.util.EventObject
java.awt.AWTEvent

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `ActionEvent, AdjustmentEvent, AncestorEvent, ComponentEvent, HierarchyEvent, InputMethodEvent, InternalFrameEvent, InvocationEvent, ItemEvent, TextEvent`

public abstract class AWTEvent extends EventObject
The root event class for all AWT events. This class and its subclasses supersede the original java.awt.Event class. Subclasses of this root AWTEvent class defined outside of the java.awt.event package should define event ID values greater than the value defined by RESERVED_ID_MAX.

The event masks defined in this class are needed by Component subclasses which are using Component.enableEvents() to select for event types not selected by registered listeners. If a listener is registered on a component, the appropriate event mask is already set internally by the component.

The masks are also used to specify to which types of events an AWTEventListener should listen. The masks are bitwise-ORed together and passed to Toolkit.addAWTEventListener.

Since:
  1.1
See Also:
  - `Component.enableEvents(long)`
  - `Toolkit.addAWTEventListener(AWTEventListener, long)`
  - `ActionEvent`
  - `AdjustmentEvent`
  - `ComponentEvent`
  - `ContainerEvent`
  - `FocusEvent`
  - `InputMethodEvent`
  - `InvocationEvent`
  - `ItemEvent`
  - `HierarchyEvent`
  - `KeyEvent`
  - `MouseEvent`
  - `MouseWheelEvent`
  - `PaintEvent`
  - `TextEvent`
  - `WindowEvent`
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `ACTION_EVENT_MASK`
  The event mask for selecting action events.
  `static final long`
  `ADJUSTMENT_EVENT_MASK`
  The event mask for selecting adjustment events.
  `static final long`
  `COMPONENT_EVENT_MASK`
  The event mask for selecting component events.
  `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.
  `static final long`
  `CONTAINER_EVENT_MASK`
  The event mask for selecting container events.
  `static final long`
  `FOCUS_EVENT_MASK`
  The event mask for selecting focus events.
  `static final long`
  `HIERARCHY_BOUNDS_EVENT_MASK`
  The event mask for selecting hierarchy bounds events.
  `static final long`
  `HIERARCHY_EVENT_MASK`
  The event mask for selecting hierarchy events.
  `protected int`
  `id`
  The event's id.
  `static final long`
  `INPUT_METHOD_EVENT_MASK`
  The event mask for selecting input method events.
  `static final long`
  `INVOCATION_EVENT_MASK`
  The event mask for selecting invocation events.
  `static final long`
  `ITEM_EVENT_MASK`
  The event mask for selecting item events.
  `static final long`
  `KEY_EVENT_MASK`
  The event mask for selecting key events.
  `static final long`
  `MOUSE_EVENT_MASK`
  The event mask for selecting mouse events.
  `static final long`
  `MOUSE_MOTION_EVENT_MASK`
  The event mask for selecting mouse motion events.
  `static final long`
  `MOUSE_WHEEL_EVENT_MASK`
  The event mask for selecting mouse wheel events.
  `static final long`
  `PAINT_EVENT_MASK`
  The event mask for selecting paint events.
  `static final int`
  `RESERVED_ID_MAX`
  The maximum value for reserved AWT event IDs.
  `static final long`
  `TEXT_EVENT_MASK`
  The event mask for selecting text events.
  `static final long`
  `WINDOW_EVENT_MASK`
  The event mask for selecting window events.
  `static final long`
  `WINDOW_FOCUS_EVENT_MASK`
  The event mask for selecting window focus events.
  `static final long`
  `WINDOW_STATE_EVENT_MASK`
  The event mask for selecting window state events.

  ### Fields declared in class EventObject

  `source`
  Modifier and Type
  Field
  Description
  `protected Object`
  `source`
  The object on which the Event initially occurred.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AWTEvent(Event event)`
  Deprecated.
  It is recommended that `AWTEvent(Object, int)` be used instead
  `AWTEvent(Object source, int id)`
  Constructs an AWTEvent object with the specified source object and type.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `consume()`
  Consumes this event, if this event can be consumed.
  `int`
  `getID()`
  Returns the event type.
  `protected boolean`
  `isConsumed()`
  Returns whether this event has been consumed.
  `String`
  `paramString()`
  Returns a string representing the state of this `Event`.
  `void`
  `setSource(Object newSource)`
  Retargets an event to a new source.
  `String`
  `toString()`
  Returns a String representation of this object.

  ### Methods declared in class EventObject

  `getSource`
  Modifier and Type
  Method
  Description
  `Object`
  `getSource()`
  The object on which the Event initially occurred.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Field Details

  - ### id

    protected int id
    The event's id.
    See Also:
      - `getID()`
      - `AWTEvent(Object, int)`

  - ### consumed

    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:
      - `consume()`
      - `isConsumed()`

  - ### COMPONENT_EVENT_MASK

    public static final long COMPONENT_EVENT_MASK
    The event mask for selecting component events.
    See Also:
      - Constant Field Values

  - ### CONTAINER_EVENT_MASK

    public static final long CONTAINER_EVENT_MASK
    The event mask for selecting container events.
    See Also:
      - Constant Field Values

  - ### FOCUS_EVENT_MASK

    public static final long FOCUS_EVENT_MASK
    The event mask for selecting focus events.
    See Also:
      - Constant Field Values

  - ### KEY_EVENT_MASK

    public static final long KEY_EVENT_MASK
    The event mask for selecting key events.
    See Also:
      - Constant Field Values

  - ### MOUSE_EVENT_MASK

    public static final long MOUSE_EVENT_MASK
    The event mask for selecting mouse events.
    See Also:
      - Constant Field Values

  - ### MOUSE_MOTION_EVENT_MASK

    public static final long MOUSE_MOTION_EVENT_MASK
    The event mask for selecting mouse motion events.
    See Also:
      - Constant Field Values

  - ### WINDOW_EVENT_MASK

    public static final long WINDOW_EVENT_MASK
    The event mask for selecting window events.
    See Also:
      - Constant Field Values

  - ### ACTION_EVENT_MASK

    public static final long ACTION_EVENT_MASK
    The event mask for selecting action events.
    See Also:
      - Constant Field Values

  - ### ADJUSTMENT_EVENT_MASK

    public static final long ADJUSTMENT_EVENT_MASK
    The event mask for selecting adjustment events.
    See Also:
      - Constant Field Values

  - ### ITEM_EVENT_MASK

    public static final long ITEM_EVENT_MASK
    The event mask for selecting item events.
    See Also:
      - Constant Field Values

  - ### TEXT_EVENT_MASK

    public static final long TEXT_EVENT_MASK
    The event mask for selecting text events.
    See Also:
      - Constant Field Values

  - ### INPUT_METHOD_EVENT_MASK

    public static final long INPUT_METHOD_EVENT_MASK
    The event mask for selecting input method events.
    See Also:
      - Constant Field Values

  - ### PAINT_EVENT_MASK

    public static final long PAINT_EVENT_MASK
    The event mask for selecting paint events.
    See Also:
      - Constant Field Values

  - ### INVOCATION_EVENT_MASK

    public static final long INVOCATION_EVENT_MASK
    The event mask for selecting invocation events.
    See Also:
      - Constant Field Values

  - ### HIERARCHY_EVENT_MASK

    public static final long HIERARCHY_EVENT_MASK
    The event mask for selecting hierarchy events.
    See Also:
      - Constant Field Values

  - ### HIERARCHY_BOUNDS_EVENT_MASK

    public static final long HIERARCHY_BOUNDS_EVENT_MASK
    The event mask for selecting hierarchy bounds events.
    See Also:
      - Constant Field Values

  - ### MOUSE_WHEEL_EVENT_MASK

    public static final long MOUSE_WHEEL_EVENT_MASK
    The event mask for selecting mouse wheel events.
    Since:
      1.4
    See Also:
      - Constant Field Values

  - ### WINDOW_STATE_EVENT_MASK

    public static final long WINDOW_STATE_EVENT_MASK
    The event mask for selecting window state events.
    Since:
      1.4
    See Also:
      - Constant Field Values

  - ### WINDOW_FOCUS_EVENT_MASK

    public static final long WINDOW_FOCUS_EVENT_MASK
    The event mask for selecting window focus events.
    Since:
      1.4
    See Also:
      - Constant Field Values

  - ### RESERVED_ID_MAX

    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

- ## Constructor Details

  - ### AWTEvent

    @Deprecated(since="9") public AWTEvent(Event event)
    Deprecated.
    It is recommended that `AWTEvent(Object, int)` be used instead
    Constructs an AWTEvent object from the parameters of a 1.0-style event.
    Parameters:
      `event` - the old-style event

  - ### AWTEvent

    public AWTEvent(Object source, int id)
    Constructs an AWTEvent object with the specified source object and type.
    Parameters:
      `source` - the object where the event originated
      `id` - the event type

- ## Method Details

  - ### setSource

    public void setSource(Object newSource)
    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

  - ### getID

    public int getID()
    Returns the event type.
    Returns:
      the event's type id

  - ### toString

    public String toString()
    Returns a String representation of this object.
    Overrides:
      `toString` in class `EventObject`
    Returns:
      a String representation of this EventObject

  - ### paramString

    public String paramString()
    Returns a string representing the state of this `Event`. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be `null`.
    Returns:
      a string representation of this event

  - ### consume

    protected void consume()
    Consumes this event, if this event can be consumed. Only low-level, system events can be consumed

  - ### isConsumed

    protected boolean isConsumed()
    Returns whether this event has been consumed.
    Returns:
      `true` if this event has been consumed; otherwise `false`