Event Objects
-
When you receive an event either in handleEvent() or in another event method,
the event you receive is described by an Event object defined in (java.awt.Event).
-
An event object contains a number of public variables that describe the
event. For example, the most often used is event.target, which is the originator
of the event. Thus, if a button is pressed and an action event is posted,
the target field will equal the button that generated the event.
-
The following table outlines some of the other properties
Value |
Description |
Object target |
The object receiving the event. |
long when |
Event time stamp. |
int id |
The type of the event. |
int x |
The x coordinate of the event. |
int y |
The y coordinate of the event. |
int key |
The key that was pressed, if any. |
int modifiers |
The state of the modifier keys, if any. |
int clickCount |
The number of consecutive mouse clicks,
if any. |
Object arg |
An arbitrary argument. |
-
You can easily use any of this information in your event handling logic
in order to perform tests, debugging or anything else.
Additional Resources:
Event
Propagation
Table of Contents
Event Modifiers
|