APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt

public abstract Class AWTEvent

extends EventObject
Class Inheritance
Known Direct Subclasses
java.awt.SentEvent, java.awt.SequencedEvent, java.awt.event.ActionEvent, java.awt.event.AdjustmentEvent, java.awt.event.ComponentEvent, java.awt.event.HierarchyEvent, java.awt.event.InputMethodEvent, java.awt.event.InvocationEvent, java.awt.event.ItemEvent, java.awt.event.TextEvent, javax.swing.event.AncestorEvent, javax.swing.event.InternalFrameEvent, sun.awt.ModalityEvent, sun.awt.UngrabEvent
Imports
java.awt.event.ActionEvent, .AdjustmentEvent, .ComponentEvent, .FocusEvent, .InputEvent, .InputMethodEvent, .ItemEvent, .KeyEvent, .MouseEvent, .TextEvent, .WindowEvent, java.awt.peer.ComponentPeer, .LightweightPeer, java.io.Serial, java.util.EventObject, sun.awt.AWTAccessor

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.

Authors
Carl Quinn, Amy Fowler
Since
1.1
See Also
Component#enableEvents, Toolkit#addAWTEventListener, java.awt.event.ActionEvent, java.awt.event.AdjustmentEvent, java.awt.event.ComponentEvent, java.awt.event.ContainerEvent, java.awt.event.FocusEvent, java.awt.event.InputMethodEvent, java.awt.event.InvocationEvent, java.awt.event.ItemEvent, java.awt.event.HierarchyEvent, java.awt.event.KeyEvent, java.awt.event.MouseEvent, java.awt.event.MouseWheelEvent, java.awt.event.PaintEvent, java.awt.event.TextEvent, java.awt.event.WindowEvent

Field Summary

Modifier and TypeField and Description
public static final long
ACTION_EVENT_MASK

The event mask for selecting action events.

public static final long
ADJUSTMENT_EVENT_MASK

The event mask for selecting adjustment events.

private byte[]
public 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.

public static final long
CONTAINER_EVENT_MASK

The event mask for selecting container events.

public static final long
FOCUS_EVENT_MASK

The event mask for selecting focus events.

pack-priv transient boolean
public static final long
HIERARCHY_BOUNDS_EVENT_MASK

The event mask for selecting hierarchy bounds events.

public static final long
HIERARCHY_EVENT_MASK

The event mask for selecting hierarchy events.

protected int
id

The event's id.

public static final long
INPUT_METHOD_EVENT_MASK

The event mask for selecting input method events.

pack-priv static final long
INPUT_METHODS_ENABLED_MASK

The pseudo event mask for enabling input methods.

public static final long
INVOCATION_EVENT_MASK

The event mask for selecting invocation events.

pack-priv transient boolean
private transient boolean
isSystemGenerated

Indicates whether this AWTEvent was generated by the system as opposed to by user code.

public static final long
ITEM_EVENT_MASK

The event mask for selecting item events.

public static final long
KEY_EVENT_MASK

The event mask for selecting key events.

public static final long
MOUSE_EVENT_MASK

The event mask for selecting mouse events.

public static final long
MOUSE_MOTION_EVENT_MASK

The event mask for selecting mouse motion events.

public static final long
MOUSE_WHEEL_EVENT_MASK

The event mask for selecting mouse wheel events.

public static final long
PAINT_EVENT_MASK

The event mask for selecting paint events.

public static final int
RESERVED_ID_MAX

The maximum value for reserved AWT event IDs.

private static final long
serialVersionUID

Hides java.util.EventObject.serialVersionUID.

Use serialVersionUID from JDK 1.1 for interoperability.
public static final long
TEXT_EVENT_MASK

The event mask for selecting text events.

public static final long
WINDOW_EVENT_MASK

The event mask for selecting window events.

public static final long
WINDOW_FOCUS_EVENT_MASK

The event mask for selecting window focus events.

public static final long
WINDOW_STATE_EVENT_MASK

The event mask for selecting window state events.

Inherited from java.util.EventObject:
source

Constructor Summary

AccessConstructor and Description
public
AWTEvent(Event
the old-style event
event
)
Deprecated since 9. It is recommended that AWTEvent(Object, int) be used instead

Constructs an AWTEvent object from the parameters of a 1.0-style event.

public
AWTEvent(Object
the object where the event originated
source
,
int
the event type
id
)

Constructs an AWTEvent object with the specified source object and type.

Method Summary

Modifier and TypeMethod and Description
protected void
consume()

Consumes this event, if this event can be consumed.

pack-priv Event
convertToOld()
References Deprecated Event is deprecated or references (maybe indirectly) at least one deprecated element.

Converts a new event to an old one (used for compatibility).

pack-priv void
copyPrivateDataInto(AWTEvent that)

Copies all private data from this event into that.

pack-priv void
public int

Returns:

the event's type id
getID
()

Returns the event type.

private static native void
initIDs()

Initialize JNI field and method IDs for fields that may be accessed from C.

protected boolean

Returns:

true if this event has been consumed; otherwise false
isConsumed
()

Returns whether this event has been consumed.

private native void
public String

Returns:

a string representation of this event
paramString
()

Returns a string representing the state of this Event.

public void
setSource(Object
the new Object to which the event should be dispatched
newSource
)

Retargets an event to a new source.

public String
toString()

Overrides java.util.EventObject.toString.

Returns a String representation of this object.

Inherited from java.util.EventObject:
getSource

Field Detail

ACTION_EVENT_MASKback to summary
public static final long ACTION_EVENT_MASK

The event mask for selecting action events.

ADJUSTMENT_EVENT_MASKback to summary
public static final long ADJUSTMENT_EVENT_MASK

The event mask for selecting adjustment events.

bdataback to summary
private byte[] bdata
COMPONENT_EVENT_MASKback to summary
public static final long COMPONENT_EVENT_MASK

The event mask for selecting component events.

consumedback to summary
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
CONTAINER_EVENT_MASKback to summary
public static final long CONTAINER_EVENT_MASK

The event mask for selecting container events.

FOCUS_EVENT_MASKback to summary
public static final long FOCUS_EVENT_MASK

The event mask for selecting focus events.

focusManagerIsDispatchingback to summary
pack-priv transient boolean focusManagerIsDispatching
HIERARCHY_BOUNDS_EVENT_MASKback to summary
public static final long HIERARCHY_BOUNDS_EVENT_MASK

The event mask for selecting hierarchy bounds events.

HIERARCHY_EVENT_MASKback to summary
public static final long HIERARCHY_EVENT_MASK

The event mask for selecting hierarchy events.

idback to summary
protected int id

The event's id.

See Also
getID(), AWTEvent
INPUT_METHOD_EVENT_MASKback to summary
public static final long INPUT_METHOD_EVENT_MASK

The event mask for selecting input method events.

INPUT_METHODS_ENABLED_MASKback to summary
pack-priv static final long INPUT_METHODS_ENABLED_MASK

The pseudo event mask for enabling input methods. We're using one bit in the eventMask so we don't need a separate field inputMethodsEnabled.

INVOCATION_EVENT_MASKback to summary
public static final long INVOCATION_EVENT_MASK

The event mask for selecting invocation events.

isPostedback to summary
pack-priv transient boolean isPosted
isSystemGeneratedback to summary
private transient boolean isSystemGenerated

Indicates whether this AWTEvent was generated by the system as opposed to by user code.

ITEM_EVENT_MASKback to summary
public static final long ITEM_EVENT_MASK

The event mask for selecting item events.

KEY_EVENT_MASKback to summary
public static final long KEY_EVENT_MASK

The event mask for selecting key events.

MOUSE_EVENT_MASKback to summary
public static final long MOUSE_EVENT_MASK

The event mask for selecting mouse events.

MOUSE_MOTION_EVENT_MASKback to summary
public static final long MOUSE_MOTION_EVENT_MASK

The event mask for selecting mouse motion events.

MOUSE_WHEEL_EVENT_MASKback to summary
public static final long MOUSE_WHEEL_EVENT_MASK

The event mask for selecting mouse wheel events.

Since
1.4
PAINT_EVENT_MASKback to summary
public static final long PAINT_EVENT_MASK

The event mask for selecting paint events.

RESERVED_ID_MAXback to summary
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.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.EventObject.serialVersionUID.

Use serialVersionUID from JDK 1.1 for interoperability.

Annotations
@Serial
TEXT_EVENT_MASKback to summary
public static final long TEXT_EVENT_MASK

The event mask for selecting text events.

WINDOW_EVENT_MASKback to summary
public static final long WINDOW_EVENT_MASK

The event mask for selecting window events.

WINDOW_FOCUS_EVENT_MASKback to summary
public static final long WINDOW_FOCUS_EVENT_MASK

The event mask for selecting window focus events.

Since
1.4
WINDOW_STATE_EVENT_MASKback to summary
public static final long WINDOW_STATE_EVENT_MASK

The event mask for selecting window state events.

Since
1.4

Constructor Detail

AWTEventback to summary
public AWTEvent(Event event)

Deprecated

since 9.

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:Event

the old-style event

Annotations
@Deprecated
since:9
AWTEventback to summary
public AWTEvent(Object source, int id)

Constructs an AWTEvent object with the specified source object and type.

Parameters
source:Object

the object where the event originated

id:int

the event type

Method Detail

consumeback to summary
protected void consume()

Consumes this event, if this event can be consumed. Only low-level, system events can be consumed

convertToOldback to summary
pack-priv Event convertToOld()

References Deprecated

Event is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Converts a new event to an old one (used for compatibility). If the new event cannot be converted (because no old equivalent exists) then this returns null.

Note

this method is here instead of in each individual new event class in java.awt.event because we don't want to make it public and it needs to be called from java.awt.

Annotations
@SuppressWarnings:deprecation
copyPrivateDataIntoback to summary
pack-priv void copyPrivateDataInto(AWTEvent that)

Copies all private data from this event into that. Space is allocated for the copied data that will be freed when the that is finalized. Upon completion, this event is not changed.

dispatchedback to summary
pack-priv void dispatched()
getIDback to summary
public int getID()

Returns the event type.

Returns:int

the event's type id

initIDsback to summary
private static native void initIDs()

Initialize JNI field and method IDs for fields that may be accessed from C.

isConsumedback to summary
protected boolean isConsumed()

Returns whether this event has been consumed.

Returns:boolean

true if this event has been consumed; otherwise false

nativeSetSourceback to summary
private native void nativeSetSource(ComponentPeer peer)
paramStringback to summary
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:String

a string representation of this event

setSourceback to summary
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:Object

the new Object to which the event should be dispatched

Since
1.4
toStringback to summary
public String toString()

Overrides java.util.EventObject.toString.

Returns a String representation of this object.