Module java.desktop
Package java.awt

Class AWTEvent

All Implemented Interfaces:
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.

See Also:
Component.enableEvents(long), Toolkit.addAWTEventListener(java.awt.event.AWTEventListener, long), ActionEvent, AdjustmentEvent, ComponentEvent, ContainerEvent, FocusEvent, InputMethodEvent, InvocationEvent, ItemEvent, HierarchyEvent, KeyEvent, MouseEvent, MouseWheelEvent, PaintEvent, TextEvent, WindowEvent, Serialized Form
  • Field Details

  • Constructor Details

    • AWTEvent

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

      public AWTEvent​(Object source, int id)
      Constructs an AWTEvent object with the specified source object and type.
      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.

      newSource - the new Object to which the event should be dispatched
    • getID

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

      public String toString()
      Returns a String representation of this object.
      toString in class EventObject
      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.
      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.
      true if this event has been consumed; otherwise false