Deprecated
since 9.
It is recommended that AWTEvent and its subclasses be
used instead
Note
The Event class is obsolete and is
available only for backwards compatibility. It has been replaced
by the AWTEvent class and its subclasses.
Event is a platform-independent class that
encapsulates events from the platform's Graphical User
Interface in the Java 1.0 event model. In Java 1.1
and later versions, the Event class is maintained
only for backwards compatibility. The information in this
class description is provided to assist programmers in
converting Java 1.0 programs to the new event model.
In the Java 1.0 event model, an event contains an
Event#id field
that indicates what type of event it is and which other
Event variables are relevant for the event.
For keyboard events, Event#key
contains a value indicating which key was activated, and
Event#modifiers contains the
modifiers for that event. For the KEY_PRESS and KEY_RELEASE
event ids, the value of key is the unicode
character code for the key. For KEY_ACTION and
KEY_ACTION_RELEASE, the value of key is
one of the defined action-key identifiers in the
Event class (PGUP,
PGDN, F1, F2, etc).
| Modifier and Type | Field and Description |
|---|---|
| public static final int | ACTION_EVENT
This event indicates that the user wants some action to occur. |
| private static final int[][] | |
| public static final int | ALT_MASK
This flag indicates that the Alt key was down when the event occurred. |
| public Object | arg
An arbitrary argument of the event. |
| public static final int | BACK_SPACE
The BackSpace key. |
| public static final int | CAPS_LOCK
The Caps Lock key, a non-ASCII action key. |
| public int | clickCount
For |
| private boolean | consumed
This field controls whether or not the event is sent back down to the peer once the target has processed it - false means it's sent to the peer, true means it's not. |
| public static final int | CTRL_MASK
This flag indicates that the Control key was down when the event occurred. |
| private transient long | |
| public static final int | DELETE
The Delete key. |
| public static final int | DOWN
The Down Arrow key, a non-ASCII action key. |
| public static final int | END
The End key, a non-ASCII action key. |
| public static final int | ENTER
The Enter key. |
| public static final int | ESCAPE
The Escape key. |
| public Event | |
| public static final int | F1
The F1 function key, a non-ASCII action key. |
| public static final int | F10
The F10 function key, a non-ASCII action key. |
| public static final int | F11
The F11 function key, a non-ASCII action key. |
| public static final int | F12
The F12 function key, a non-ASCII action key. |
| public static final int | F2
The F2 function key, a non-ASCII action key. |
| public static final int | F3
The F3 function key, a non-ASCII action key. |
| public static final int | F4
The F4 function key, a non-ASCII action key. |
| public static final int | F5
The F5 function key, a non-ASCII action key. |
| public static final int | F6
The F6 function key, a non-ASCII action key. |
| public static final int | F7
The F7 function key, a non-ASCII action key. |
| public static final int | F8
The F8 function key, a non-ASCII action key. |
| public static final int | F9
The F9 function key, a non-ASCII action key. |
| public static final int | GOT_FOCUS
A component gained the focus. |
| public static final int | HOME
The Home key, a non-ASCII action key. |
| public int | id
Indicates which type of event the event is, and which
other |
| public static final int | INSERT
The Insert key, a non-ASCII action key. |
| public int | key
The key code of the key that was pressed in a keyboard event. |
| public static final int | KEY_ACTION
The user has pressed a non-ASCII action key. |
| public static final int | KEY_ACTION_RELEASE
The user has released a non-ASCII action key. |
| private static final int | |
| public static final int | KEY_PRESS
The user has pressed a normal key. |
| public static final int | KEY_RELEASE
The user has released a normal key. |
| public static final int | LEFT
The Left Arrow key, a non-ASCII action key. |
| public static final int | LIST_DESELECT
An item in a list has been deselected. |
| private static final int | |
| public static final int | LIST_SELECT
An item in a list has been selected. |
| public static final int | LOAD_FILE
A file loading event. |
| public static final int | LOST_FOCUS
A component lost the focus. |
| public static final int | META_MASK
This flag indicates that the Meta key was down when the event occurred. |
| private static final int | |
| public int | modifiers
The state of the modifier keys. |
| public static final int | MOUSE_DOWN
The user has pressed the mouse button. |
| public static final int | MOUSE_DRAG
The user has moved the mouse with a button pressed. |
| public static final int | MOUSE_ENTER
The mouse has entered a component. |
| private static final int | |
| public static final int | MOUSE_EXIT
The mouse has exited a component. |
| public static final int | MOUSE_MOVE
The mouse has moved with no button pressed. |
| public static final int | MOUSE_UP
The user has released the mouse button. |
| public static final int | NUM_LOCK
The Num Lock key, a non-ASCII action key. |
| public static final int | PAUSE
The Pause key, a non-ASCII action key. |
| public static final int | PGDN
The Page Down key, a non-ASCII action key. |
| public static final int | PGUP
The Page Up key, a non-ASCII action key. |
| public static final int | PRINT_SCREEN
The Print Screen key, a non-ASCII action key. |
| public static final int | RIGHT
The Right Arrow key, a non-ASCII action key. |
| public static final int | SAVE_FILE
A file saving event. |
| public static final int | SCROLL_ABSOLUTE
The user has moved the bubble (thumb) in a scroll bar, moving to an "absolute" position, rather than to an offset from the last position. |
| public static final int | SCROLL_BEGIN
The scroll begin event. |
| public static final int | SCROLL_END
The scroll end event. |
| private static final int | |
| public static final int | SCROLL_LINE_DOWN
The user has activated the line down area of a scroll bar. |
| public static final int | SCROLL_LINE_UP
The user has activated the line up area of a scroll bar. |
| public static final int | SCROLL_LOCK
The Scroll Lock key, a non-ASCII action key. |
| public static final int | SCROLL_PAGE_DOWN
The user has activated the page down area of a scroll bar. |
| public static final int | SCROLL_PAGE_UP
The user has activated the page up area of a scroll bar. |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability. |
| public static final int | SHIFT_MASK
This flag indicates that the Shift key was down when the event occurred. |
| public static final int | TAB
The Tab key. |
| public Object | target
The target component. |
| public static final int | UP
The Up Arrow key, a non-ASCII action key. |
| public long | when
The time stamp. |
| public static final int | WINDOW_DEICONIFY
The user has asked the window manager to de-iconify the window. |
| public static final int | WINDOW_DESTROY
The user has asked the window manager to kill the window. |
| private static final int | |
| public static final int | WINDOW_EXPOSE
The user has asked the window manager to expose the window. |
| public static final int | WINDOW_ICONIFY
The user has asked the window manager to iconify the window. |
| public static final int | WINDOW_MOVED
The user has asked the window manager to move the window. |
| public int | x
The x coordinate of the event. |
| public int | y
The y coordinate of the event. |
| Access | Constructor and Description |
|---|---|
| public | Event(Object
the target component. target, long the time stamp. when, int the event type. id, int the x coordinate. x, int the y coordinate. y, int the key pressed in a keyboard event. key, int the state of the modifier keys. modifiers, Object the specified argument. arg)
Creates an instance of |
| public | Event(Object
the target component. target, long the time stamp. when, int the event type. id, int the x coordinate. x, int the y coordinate. y, int the key pressed in a keyboard event. key, int the state of the modifier keys. modifiers)
Creates an instance of |
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public boolean | |
| pack-priv char | |
| pack-priv static int | |
| private static native void | |
| pack-priv boolean | |
| public boolean | |
| protected String | Returns: the parameter string of this event
Returns a string representing the state of this |
| public boolean | |
| public String | Returns: a string that represents the event and the values of its member fields.Overrides java. Returns a representation of this event's values as a string. |
| public void | translate(int
the distance to translate the x coordinate. dx, int the distance to translate the y coordinate. dy)Translates this event so that its x and y coordinates are increased by dx and dy, respectively. |
| ACTION_EVENT | back to summary |
|---|---|
| public static final int ACTION_EVENT This event indicates that the user wants some action to occur. | |
| actionKeyCodes | back to summary |
|---|---|
| private static final int[][] actionKeyCodes | |
| ALT_MASK | back to summary |
|---|---|
| public static final int ALT_MASK This flag indicates that the Alt key was down when the event occurred. For mouse events, this flag indicates that the middle mouse button was pressed or released. | |
| arg | back to summary |
|---|---|
| public Object arg An arbitrary argument of the event. The value of this field
depends on the type of event.
| |
| BACK_SPACE | back to summary |
|---|---|
| public static final int BACK_SPACE The BackSpace key. | |
| CAPS_LOCK | back to summary |
|---|---|
| public static final int CAPS_LOCK The Caps Lock key, a non-ASCII action key. | |
| clickCount | back to summary |
|---|---|
| public int clickCount For | |
| consumed | back to summary |
|---|---|
| private boolean consumed This field controls whether or not the event is sent back down to the peer once the target has processed it - false means it's sent to the peer, true means it's not.
| |
| CTRL_MASK | back to summary |
|---|---|
| public static final int CTRL_MASK This flag indicates that the Control key was down when the event occurred. | |
| data | back to summary |
|---|---|
| private transient long data | |
| DELETE | back to summary |
|---|---|
| public static final int DELETE The Delete key. | |
| DOWN | back to summary |
|---|---|
| public static final int DOWN The Down Arrow key, a non-ASCII action key. | |
| END | back to summary |
|---|---|
| public static final int END The End key, a non-ASCII action key. | |
| ENTER | back to summary |
|---|---|
| public static final int ENTER The Enter key. | |
| ESCAPE | back to summary |
|---|---|
| public static final int ESCAPE The Escape key. | |
| evt | back to summary |
|---|---|
| public Event evt
References Deprecated
See corresponding docs for further information. The next event. This field is set when putting events into a linked list. This has been replaced by EventQueue.
| |
| F1 | back to summary |
|---|---|
| public static final int F1 The F1 function key, a non-ASCII action key. | |
| F10 | back to summary |
|---|---|
| public static final int F10 The F10 function key, a non-ASCII action key. | |
| F11 | back to summary |
|---|---|
| public static final int F11 The F11 function key, a non-ASCII action key. | |
| F12 | back to summary |
|---|---|
| public static final int F12 The F12 function key, a non-ASCII action key. | |
| F2 | back to summary |
|---|---|
| public static final int F2 The F2 function key, a non-ASCII action key. | |
| F3 | back to summary |
|---|---|
| public static final int F3 The F3 function key, a non-ASCII action key. | |
| F4 | back to summary |
|---|---|
| public static final int F4 The F4 function key, a non-ASCII action key. | |
| F5 | back to summary |
|---|---|
| public static final int F5 The F5 function key, a non-ASCII action key. | |
| F6 | back to summary |
|---|---|
| public static final int F6 The F6 function key, a non-ASCII action key. | |
| F7 | back to summary |
|---|---|
| public static final int F7 The F7 function key, a non-ASCII action key. | |
| F8 | back to summary |
|---|---|
| public static final int F8 The F8 function key, a non-ASCII action key. | |
| F9 | back to summary |
|---|---|
| public static final int F9 The F9 function key, a non-ASCII action key. | |
| GOT_FOCUS | back to summary |
|---|---|
| public static final int GOT_FOCUS A component gained the focus. | |
| HOME | back to summary |
|---|---|
| public static final int HOME The Home key, a non-ASCII action key. | |
| id | back to summary |
|---|---|
| public int id Indicates which type of event the event is, and which
other
| |
| INSERT | back to summary |
|---|---|
| public static final int INSERT The Insert key, a non-ASCII action key. | |
| key | back to summary |
|---|---|
| public int key The key code of the key that was pressed in a keyboard event. This has been replaced by KeyEvent.getKeyCode()
| |
| KEY_ACTION | back to summary |
|---|---|
| public static final int KEY_ACTION The user has pressed a non-ASCII action key.
The | |
| KEY_ACTION_RELEASE | back to summary |
|---|---|
| public static final int KEY_ACTION_RELEASE The user has released a non-ASCII action key.
The | |
| KEY_EVENT | back to summary |
|---|---|
| private static final int KEY_EVENT | |
| KEY_PRESS | back to summary |
|---|---|
| public static final int KEY_PRESS The user has pressed a normal key. | |
| KEY_RELEASE | back to summary |
|---|---|
| public static final int KEY_RELEASE The user has released a normal key. | |
| LEFT | back to summary |
|---|---|
| public static final int LEFT The Left Arrow key, a non-ASCII action key. | |
| LIST_DESELECT | back to summary |
|---|---|
| public static final int LIST_DESELECT An item in a list has been deselected. | |
| LIST_EVENT | back to summary |
|---|---|
| private static final int LIST_EVENT | |
| LIST_SELECT | back to summary |
|---|---|
| public static final int LIST_SELECT An item in a list has been selected. | |
| LOAD_FILE | back to summary |
|---|---|
| public static final int LOAD_FILE A file loading event. | |
| LOST_FOCUS | back to summary |
|---|---|
| public static final int LOST_FOCUS A component lost the focus. | |
| META_MASK | back to summary |
|---|---|
| public static final int META_MASK This flag indicates that the Meta key was down when the event occurred. For mouse events, this flag indicates that the right button was pressed or released. | |
| MISC_EVENT | back to summary |
|---|---|
| private static final int MISC_EVENT | |
| modifiers | back to summary |
|---|---|
| public int modifiers The state of the modifier keys. This is replaced with InputEvent.getModifiers() In java 1.1 MouseEvent and KeyEvent are subclasses of InputEvent. | |
| MOUSE_DOWN | back to summary |
|---|---|
| public static final int MOUSE_DOWN The user has pressed the mouse button. The | |
| MOUSE_DRAG | back to summary |
|---|---|
| public static final int MOUSE_DRAG The user has moved the mouse with a button pressed. The
| |
| MOUSE_ENTER | back to summary |
|---|---|
| public static final int MOUSE_ENTER The mouse has entered a component. | |
| MOUSE_EVENT | back to summary |
|---|---|
| private static final int MOUSE_EVENT | |
| MOUSE_EXIT | back to summary |
|---|---|
| public static final int MOUSE_EXIT The mouse has exited a component. | |
| MOUSE_MOVE | back to summary |
|---|---|
| public static final int MOUSE_MOVE The mouse has moved with no button pressed. | |
| MOUSE_UP | back to summary |
|---|---|
| public static final int MOUSE_UP The user has released the mouse button. The | |
| NUM_LOCK | back to summary |
|---|---|
| public static final int NUM_LOCK The Num Lock key, a non-ASCII action key. | |
| PAUSE | back to summary |
|---|---|
| public static final int PAUSE The Pause key, a non-ASCII action key. | |
| PGDN | back to summary |
|---|---|
| public static final int PGDN The Page Down key, a non-ASCII action key. | |
| PGUP | back to summary |
|---|---|
| public static final int PGUP The Page Up key, a non-ASCII action key. | |
| PRINT_SCREEN | back to summary |
|---|---|
| public static final int PRINT_SCREEN The Print Screen key, a non-ASCII action key. | |
| RIGHT | back to summary |
|---|---|
| public static final int RIGHT The Right Arrow key, a non-ASCII action key. | |
| SAVE_FILE | back to summary |
|---|---|
| public static final int SAVE_FILE A file saving event. | |
| SCROLL_ABSOLUTE | back to summary |
|---|---|
| public static final int SCROLL_ABSOLUTE The user has moved the bubble (thumb) in a scroll bar, moving to an "absolute" position, rather than to an offset from the last position. | |
| SCROLL_BEGIN | back to summary |
|---|---|
| public static final int SCROLL_BEGIN The scroll begin event. | |
| SCROLL_END | back to summary |
|---|---|
| public static final int SCROLL_END The scroll end event. | |
| SCROLL_EVENT | back to summary |
|---|---|
| private static final int SCROLL_EVENT | |
| SCROLL_LINE_DOWN | back to summary |
|---|---|
| public static final int SCROLL_LINE_DOWN The user has activated the line down area of a scroll bar. | |
| SCROLL_LINE_UP | back to summary |
|---|---|
| public static final int SCROLL_LINE_UP The user has activated the line up area of a scroll bar. | |
| SCROLL_LOCK | back to summary |
|---|---|
| public static final int SCROLL_LOCK The Scroll Lock key, a non-ASCII action key. | |
| SCROLL_PAGE_DOWN | back to summary |
|---|---|
| public static final int SCROLL_PAGE_DOWN The user has activated the page down area of a scroll bar. | |
| SCROLL_PAGE_UP | back to summary |
|---|---|
| public static final int SCROLL_PAGE_UP The user has activated the page up area of a scroll bar. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Use serialVersionUID from JDK 1.1 for interoperability. | |
| SHIFT_MASK | back to summary |
|---|---|
| public static final int SHIFT_MASK This flag indicates that the Shift key was down when the event occurred. | |
| TAB | back to summary |
|---|---|
| public static final int TAB The Tab key. | |
| target | back to summary |
|---|---|
| public Object target The target component. This indicates the component over which the event occurred or with which the event is associated. This object has been replaced by AWTEvent.getSource()
| |
| UP | back to summary |
|---|---|
| public static final int UP The Up Arrow key, a non-ASCII action key. | |
| when | back to summary |
|---|---|
| public long when The time stamp. Replaced by InputEvent.getWhen().
| |
| WINDOW_DEICONIFY | back to summary |
|---|---|
| public static final int WINDOW_DEICONIFY The user has asked the window manager to de-iconify the window. | |
| WINDOW_DESTROY | back to summary |
|---|---|
| public static final int WINDOW_DESTROY The user has asked the window manager to kill the window. | |
| WINDOW_EVENT | back to summary |
|---|---|
| private static final int WINDOW_EVENT | |
| WINDOW_EXPOSE | back to summary |
|---|---|
| public static final int WINDOW_EXPOSE The user has asked the window manager to expose the window. | |
| WINDOW_ICONIFY | back to summary |
|---|---|
| public static final int WINDOW_ICONIFY The user has asked the window manager to iconify the window. | |
| WINDOW_MOVED | back to summary |
|---|---|
| public static final int WINDOW_MOVED The user has asked the window manager to move the window. | |
| x | back to summary |
|---|---|
| public int x The x coordinate of the event. Replaced by MouseEvent.getX()
| |
| y | back to summary |
|---|---|
| public int y The y coordinate of the event. Replaced by MouseEvent.getY()
| |
| Event | back to summary |
|---|---|
| public Event(Object target, long when, int id, int x, int y, int key, int modifiers, Object arg) Note The
Creates an instance of | |
| Event | back to summary |
|---|---|
| public Event(Object target, long when, int id, int x, int y, int key, int modifiers) Note The
Creates an instance of
| |
| Event | back to summary |
|---|---|
| public Event(Object target, int id, Object arg) Note The
Creates an instance of | |
| consume | back to summary |
|---|---|
| pack-priv void consume() Note The | |
| controlDown | back to summary |
|---|---|
| public boolean controlDown() Note The Checks if the Control key is down.
| |
| getKeyEventChar | back to summary |
|---|---|
| pack-priv char getKeyEventChar() | |
| getOldEventKey | back to summary |
|---|---|
| pack-priv static int getOldEventKey(KeyEvent e) | |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() Initialize JNI field and method IDs for fields that may be accessed from C. | |
| isConsumed | back to summary |
|---|---|
| pack-priv boolean isConsumed() Note The | |
| metaDown | back to summary |
|---|---|
| public boolean metaDown() Note The Checks if the Meta key is down.
| |
| paramString | back to summary |
|---|---|
| protected String paramString() Note The
Returns a string representing the state of this
| |
| shiftDown | back to summary |
|---|---|
| public boolean shiftDown() Note The Checks if the Shift key is down.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Note The Returns a representation of this event's values as a string.
| |
| translate | back to summary |
|---|---|
| public void translate(int dx, int dy) Note The Translates this event so that its x and y coordinates are increased by dx and dy, respectively. This method translates an event relative to the given component. This involves, at a minimum, translating the coordinates into the local coordinate system of the given component. It may also involve translating a region in the case of an expose event.
| |