java.awt
Class Event

java.lang.Object
  |
  +--java.awt.Event

public class Event
extends Object

Event is a platform-independent class that encapsulates events from the local Graphical User Interface(GUI) platform.

The event contains an id which indicates the type of event it is and which other Event variables are relavent for the event. For keyboard events, key will contain a value indicating the key that was activated and modifiers will contain the modifiers. For KEY_PRESS and KEY_RELEASE event ids, the value of key will be the unicode character code for the key; for KEY_ACTION and KEY_ACTION_RELEASE, the value of key will be one of the defined action-key identifiers in the Event class (PGUP, PGDN, F1, F2, etc).


Field Summary
static int ACTION_EVENT
          An action event.
static int ALT_MASK
          The alt modifier constant.
 Object arg
          An arbitrary argument.
 int clickCount
          The number of consecutive clicks.
static int CTRL_MASK
          The control modifier constant.
static int DOWN
          The down arrow action-key.
static int END
          The end action-key.
 Event evt
          The next event.
static int F1
          The F1 function action-key.
static int F10
          The F10 function action-key.
static int F11
          The F11 function action-key.
static int F12
          The F12 function action-key.
static int F2
          The F2 function action-key.
static int F3
          The F3 function action-key.
static int F4
          The F4 function action-key.
static int F5
          The F5 function action-key.
static int F6
          The F6 function action-key.
static int F7
          The F7 function action-key.
static int F8
          The F8 function action-key.
static int F9
          The F9 function action-key.
static int GOT_FOCUS
          A component gained the focus.
static int HOME
          The home action-key.
 int id
          The type of this event.
 int key
          The key that was pressed in a keyboard event.
static int KEY_ACTION
          The action-key press keyboard event.
static int KEY_ACTION_RELEASE
          The action-key release keyboard event.
static int KEY_PRESS
          The key press keyboard event.
static int KEY_RELEASE
          The key release keyboard event.
static int LEFT
          The left arrow action-key.
static int LIST_DESELECT
           
static int LIST_SELECT
           
static int LOAD_FILE
          A file loading event.
static int LOST_FOCUS
          A component lost the focus.
static int META_MASK
          The meta modifier constant.
 int modifiers
          The state of the modifier keys.
static int MOUSE_DOWN
          The mouse down event.
static int MOUSE_DRAG
          The mouse drag event.
static int MOUSE_ENTER
          The mouse enter event.
static int MOUSE_EXIT
          The mouse exit event.
static int MOUSE_MOVE
          The mouse move event.
static int MOUSE_UP
          The mouse up event.
static int PGDN
          The page down action-key.
static int PGUP
          The page up action-key.
static int RIGHT
          The right arrow action-key.
static int SAVE_FILE
          A file saving event.
static int SCROLL_ABSOLUTE
          The absolute scroll event.
static int SCROLL_LINE_DOWN
          The line down scroll event.
static int SCROLL_LINE_UP
          The line up scroll event.
static int SCROLL_PAGE_DOWN
          The page down scroll event.
static int SCROLL_PAGE_UP
          The page up scroll event.
static int SHIFT_MASK
          The shift modifier constant.
 Object target
          The target component.
static int UP
          The up arrow action-key.
 long when
          The time stamp.
static int WINDOW_DEICONIFY
          The de-iconify window event.
static int WINDOW_DESTROY
          The destroy window event.
static int WINDOW_EXPOSE
          The expose window event.
static int WINDOW_ICONIFY
          The iconify window event.
static int WINDOW_MOVED
          The move window event.
 int x
          The x coordinate of the event.
 int y
          The y coordinate of the event.
 
Constructor Summary
Event(Object target, int id, Object arg)
          Constructs an event with the specified target component, event type, and argument.
Event(Object target, long when, int id, int x, int y, int key, int modifiers)
          Constructs an event with the specified target component, time stamp, event type, x and y coordinates, keyboard key, state of the modifier keys and an argument set to null.
Event(Object target, long when, int id, int x, int y, int key, int modifiers, Object arg)
          Constructs an event with the specified target component, time stamp, event type, x and y coordinates, keyboard key, state of the modifier keys and argument.
 
Method Summary
 boolean controlDown()
          Checks if the control key is down.
 boolean metaDown()
          Checks if the meta key is down.
protected  String paramString()
          Returns the parameter String of this Event.
 boolean shiftDown()
          Checks if the shift key is down.
 String toString()
          Returns the String representation of this Event's values.
 void translate(int x, int y)
          Translates an event relative to the given component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SHIFT_MASK

public static final int SHIFT_MASK
The shift modifier constant.

See Also:
Constant Field Values

CTRL_MASK

public static final int CTRL_MASK
The control modifier constant.

See Also:
Constant Field Values

META_MASK

public static final int META_MASK
The meta modifier constant.

See Also:
Constant Field Values

ALT_MASK

public static final int ALT_MASK
The alt modifier constant.

See Also:
Constant Field Values

HOME

public static final int HOME
The home action-key.

See Also:
Constant Field Values

END

public static final int END
The end action-key.

See Also:
Constant Field Values

PGUP

public static final int PGUP
The page up action-key.

See Also:
Constant Field Values

PGDN

public static final int PGDN
The page down action-key.

See Also:
Constant Field Values

UP

public static final int UP
The up arrow action-key.

See Also:
Constant Field Values

DOWN

public static final int DOWN
The down arrow action-key.

See Also:
Constant Field Values

LEFT

public static final int LEFT
The left arrow action-key.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
The right arrow action-key.

See Also:
Constant Field Values

F1

public static final int F1
The F1 function action-key.

See Also:
Constant Field Values

F2

public static final int F2
The F2 function action-key.

See Also:
Constant Field Values

F3

public static final int F3
The F3 function action-key.

See Also:
Constant Field Values

F4

public static final int F4
The F4 function action-key.

See Also:
Constant Field Values

F5

public static final int F5
The F5 function action-key.

See Also:
Constant Field Values

F6

public static final int F6
The F6 function action-key.

See Also:
Constant Field Values

F7

public static final int F7
The F7 function action-key.

See Also:
Constant Field Values

F8

public static final int F8
The F8 function action-key.

See Also:
Constant Field Values

F9

public static final int F9
The F9 function action-key.

See Also:
Constant Field Values

F10

public static final int F10
The F10 function action-key.

See Also:
Constant Field Values

F11

public static final int F11
The F11 function action-key.

See Also:
Constant Field Values

F12

public static final int F12
The F12 function action-key.

See Also:
Constant Field Values

WINDOW_DESTROY

public static final int WINDOW_DESTROY
The destroy window event.

See Also:
Constant Field Values

WINDOW_EXPOSE

public static final int WINDOW_EXPOSE
The expose window event.

See Also:
Constant Field Values

WINDOW_ICONIFY

public static final int WINDOW_ICONIFY
The iconify window event.

See Also:
Constant Field Values

WINDOW_DEICONIFY

public static final int WINDOW_DEICONIFY
The de-iconify window event.

See Also:
Constant Field Values

WINDOW_MOVED

public static final int WINDOW_MOVED
The move window event.

See Also:
Constant Field Values

KEY_PRESS

public static final int KEY_PRESS
The key press keyboard event.

See Also:
Constant Field Values

KEY_RELEASE

public static final int KEY_RELEASE
The key release keyboard event.

See Also:
Constant Field Values

KEY_ACTION

public static final int KEY_ACTION
The action-key press keyboard event.

See Also:
Constant Field Values

KEY_ACTION_RELEASE

public static final int KEY_ACTION_RELEASE
The action-key release keyboard event.

See Also:
Constant Field Values

MOUSE_DOWN

public static final int MOUSE_DOWN
The mouse down event.

See Also:
Constant Field Values

MOUSE_UP

public static final int MOUSE_UP
The mouse up event.

See Also:
Constant Field Values

MOUSE_MOVE

public static final int MOUSE_MOVE
The mouse move event.

See Also:
Constant Field Values

MOUSE_ENTER

public static final int MOUSE_ENTER
The mouse enter event.

See Also:
Constant Field Values

MOUSE_EXIT

public static final int MOUSE_EXIT
The mouse exit event.

See Also:
Constant Field Values

MOUSE_DRAG

public static final int MOUSE_DRAG
The mouse drag event.

See Also:
Constant Field Values

SCROLL_LINE_UP

public static final int SCROLL_LINE_UP
The line up scroll event.

See Also:
Constant Field Values

SCROLL_LINE_DOWN

public static final int SCROLL_LINE_DOWN
The line down scroll event.

See Also:
Constant Field Values

SCROLL_PAGE_UP

public static final int SCROLL_PAGE_UP
The page up scroll event.

See Also:
Constant Field Values

SCROLL_PAGE_DOWN

public static final int SCROLL_PAGE_DOWN
The page down scroll event.

See Also:
Constant Field Values

SCROLL_ABSOLUTE

public static final int SCROLL_ABSOLUTE
The absolute scroll event.

See Also:
Constant Field Values

LIST_SELECT

public static final int LIST_SELECT
See Also:
Constant Field Values

LIST_DESELECT

public static final int LIST_DESELECT
See Also:
Constant Field Values

ACTION_EVENT

public static final int ACTION_EVENT
An action event.

See Also:
Constant Field Values

LOAD_FILE

public static final int LOAD_FILE
A file loading event.

See Also:
Constant Field Values

SAVE_FILE

public static final int SAVE_FILE
A file saving event.

See Also:
Constant Field Values

GOT_FOCUS

public static final int GOT_FOCUS
A component gained the focus.

See Also:
Constant Field Values

LOST_FOCUS

public static final int LOST_FOCUS
A component lost the focus.

See Also:
Constant Field Values

target

public Object target
The target component.


when

public long when
The time stamp.


id

public int id
The type of this event.


x

public int x
The x coordinate of the event.


y

public int y
The y coordinate of the event.


key

public int key
The key that was pressed in a keyboard event.


modifiers

public int modifiers
The state of the modifier keys.


clickCount

public int clickCount
The number of consecutive clicks. This field is relevant only for MOUSE_DOWN events. If the field isn't set it will be 0. Otherwise, it will be 1 for single-clicks, 2 for double-clicks, and so on.


arg

public Object arg
An arbitrary argument.


evt

public Event evt
The next event. Used when putting events into a linked list.

Constructor Detail

Event

public Event(Object target,
             long when,
             int id,
             int x,
             int y,
             int key,
             int modifiers,
             Object arg)
Constructs an event with the specified target component, time stamp, event type, x and y coordinates, keyboard key, state of the modifier keys and argument.

Parameters:
target - the target component
when - the time stamp
id - the event type
x - the x coordinate
y - the y coordinate
key - the key pressed in a keyboard event
modifiers - the state of the modifier keys
arg - the specified argument

Event

public Event(Object target,
             long when,
             int id,
             int x,
             int y,
             int key,
             int modifiers)
Constructs an event with the specified target component, time stamp, event type, x and y coordinates, keyboard key, state of the modifier keys and an argument set to null.

Parameters:
target - the target component
when - the time stamp
id - the event type
x - the x coordinate
y - the y coordinate
key - the key pressed in a keyboard event
modifiers - the state of the modifier keys

Event

public Event(Object target,
             int id,
             Object arg)
Constructs an event with the specified target component, event type, and argument.

Parameters:
target - the target component
id - the event type
arg - the specified argument
Method Detail

translate

public void translate(int x,
                      int y)
Translates an event relative to the given component. This involves at a minimum translating the coordinates so they make sense within the given component. It may also involve translating a region in the case of an expose event.

Parameters:
x - the x coordinate
y - the y coordinate

shiftDown

public boolean shiftDown()
Checks if the shift key is down.

See Also:
modifiers, controlDown(), metaDown()

controlDown

public boolean controlDown()
Checks if the control key is down.

See Also:
modifiers, shiftDown(), metaDown()

metaDown

public boolean metaDown()
Checks if the meta key is down.

See Also:
modifiers, shiftDown(), controlDown()

paramString

protected String paramString()
Returns the parameter String of this Event.


toString

public String toString()
Returns the String representation of this Event's values.

Overrides:
toString in class Object