Packages  This Package  Prev  Next  Index  

§1.14 Class Event

public  class  java.awt.Event
    extends  java.lang.Object  (I-§1.12)
{
        // Fields
    public Object arg;	§1.14.1
    public int clickCount;	§1.14.2
    public Event evt;	§1.14.3
    public int id;	§1.14.4
    public int key;	§1.14.5
    public int modifiers;	§1.14.6
    public Object target;	§1.14.7
    public long when;	§1.14.8
    public int x;	§1.14.9
    public int y;	§1.14.10

      // possible values for the id field	
    public final static int ACTION_EVENT;	§1.14.11
    public final static int GOT_FOCUS;	§1.14.12
    public final static int KEY_ACTION;	§1.14.13
    public final static int KEY_ACTION_RELEASE;	§1.14.14
    public final static int KEY_PRESS;	§1.14.15
    public final static int KEY_RELEASE;	§1.14.16
    public final static int LIST_DESELECT;	§1.14.17
    public final static int LIST_SELECT;	§1.14.18
    public final static int LOAD_FILE;	§1.14.19
    public final static int LOST_FOCUS;	§1.14.20
    public final static int MOUSE_DOWN;	§1.14.21
    public final static int MOUSE_DRAG;	§1.14.22
    public final static int MOUSE_ENTER;	§1.14.23
    public final static int MOUSE_EXIT;	§1.14.24
    public final static int MOUSE_MOVE;	§1.14.25
    public final static int MOUSE_UP;	§1.14.26
    public final static int SAVE_FILE;	§1.14.27
    public final static int SCROLL_ABSOLUTE;	§1.14.28
    public final static int SCROLL_LINE_DOWN;	§1.14.29
    public final static int SCROLL_LINE_UP;	§1.14.30
    public final static int SCROLL_PAGE_DOWN;	§1.14.31
    public final static int SCROLL_PAGE_UP;	§1.14.32
    public final static int WINDOW_DEICONIFY;	§1.14.33
    public final static int WINDOW_DESTROY;	§1.14.34
    public final static int WINDOW_EXPOSE;	§1.14.35
    public final static int WINDOW_ICONIFY;	§1.14.36
    public final static int WINDOW_MOVED;	§1.14.37

      // possible values for the key field when the
        // action is KEY_ACTION or KEY_ACTION_RELEASE	
    public final static int DOWN;	§1.14.38
    public final static int END;	§1.14.39
    public final static int F1;	§1.14.40
    public final static int F2;	§1.14.41
    public final static int F3;	§1.14.42
    public final static int F4;	§1.14.43
    public final static int F5;	§1.14.44
    public final static int F6;	§1.14.45
    public final static int F7;	§1.14.46
    public final static int F8;	§1.14.47
    public final static int F9;	§1.14.48
    public final static int F10;	§1.14.49
    public final static int F11;	§1.14.50
    public final static int F12;	§1.14.51
    public final static int HOME;	§1.14.52
    public final static int LEFT;	§1.14.53
    public final static int PGDN;	§1.14.54
    public final static int PGUP;	§1.14.55
    public final static int RIGHT;	§1.14.56
    public final static int UP;	§1.14.57

        // possible masks for the modifiers field 
    public final static int ALT_MASK	§1.14.58
    public final static int CTRL_MASK;	§1.14.59
    public final static int META_MASK;	§1.14.61
    public final static int SHIFT_MASK;	§1.14.60

        // Constructors
    public Event(Object  target, int  id, Object  arg);	§1.14.62
    public Event(Object  target, long  when, int id,	§1.14.63
              int  x, int  y, int  key, int  modifiers);
    public Event(Object  target, long  when, int id, 	§1.14.64
                   int  x, int  y, int  key,
                   int  modifiers, Object  arg);

        // Methods
    public boolean controlDown();	§1.14.65
    public boolean metaDown();	§1.14.66
    protected String paramString();	§1.14.67
    public boolean shiftDown();	§1.14.68
    public String toString();	§1.14.69
    public void translate(int  dX, int  dY);	§1.14.70
}
Event is a platform-independent class that encapsulates user events from the local Graphical User Interface (GUI) platform.


Fields

arg

public Object arg
An arbitrary argument of the event. The value of this field depends on the type of event.

clickCount

public int clickCount
For MOUSE_DOWN events, this field indicates the number of consecutive clicks. For other events, it is zero.

evt

public Event evt
The next event. This field is set when putting events into a linked list.

id

public int id
The type 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.

target

public Object target
The target component. This indicates the component over which the event occurred or with which the event is associated.

when

public long when
The time stamp of the event.

x

public int x
The x coordinate of the event.

y

public int y
The y coordinate of the event.

ACTION_EVENT

public final static int ACTION_EVENT = 1001
This event indicates that the user wants some action to occur.

GOT_FOCUS

public final static int GOT_FOCUS = 1004
A component gained the focus.

KEY_ACTION

public final static int KEY_ACTION = 403
The user has pressed an "action" key. The key field contains one of the special values indicated in §1.14.38 to §1.14.57.

KEY_ACTION_RELEASE

public final static int KEY_ACTION_RELEASE = 404
The user has released an "action" key. The key field contains one of the special values indicated in §1.14.38 to §1.14.57.

KEY_PRESS

public final static int KEY_PRESS = 401
The user has pressed a normal key.

KEY_RELEASE

public final static int KEY_RELEASE = 402
The user has released a normal key.

LIST_DESELECT

public final static int LIST_DESELECT = 702
An item in a list has been deselected.

LIST_SELECT

public final static int LIST_SELECT = 701
An item in a list has been selected.

LOAD_FILE

public final static int LOAD_FILE = 1002
A file loading event.

LOST_FOCUS

public final static int LOST_FOCUS = 1005
A component lost the focus.

MOUSE_DOWN

public final static int MOUSE_DOWN = 501
The user has pressed the mouse button. The ALT_MASK (II-§1.14.58) flag indicates that the middle button has been pushed. The META_MASK (II-§1.14.61) flag indicates that the right button has been pushed.

MOUSE_DRAG

public final static int MOUSE_DRAG = 506
The user has moved the mouse with a button pushed. The ALT_MASK (II-§1.14.58) flag indicates that the middle button is being pushed. The META_MASK (II-§1.14.61) flag indicates that the right button is pushed pushed.

MOUSE_ENTER

public final static int MOUSE_ENTER = 504
The mouse has entered a component.

MOUSE_EXIT

public final static int MOUSE_EXIT = 505
The mouse has exited a component.

MOUSE_MOVE

public final static int MOUSE_MOVE = 503
The mouse has moved with no button pressed.

MOUSE_UP

public final static int MOUSE_UP = 502
The user has released the mouse button. The ALT_MASK (II-§1.14.58) flag indicates that the middle button has been pushed. The META_MASK (II-§1.14.61) flag indicates that the right button has been pushed.

SAVE_FILE

public final static int SAVE_FILE = 1003
A file saving event.

SCROLL_ABSOLUTE

public final static int SCROLL_ABSOLUTE = 605
The user has moved the bubble in a scroll bar.

SCROLL_LINE_DOWN

public final static int SCROLL_LINE_DOWN = 602
The user has pushed the "line down" area of a scroll bar.

SCROLL_LINE_UP

public final static int SCROLL_LINE_UP = 601
The user has pushed the "line up" area of a scroll bar.

SCROLL_PAGE_DOWN

public final static int SCROLL_PAGE_DOWN = 604
The user has pushed the "page down" area of a scroll bar.

SCROLL_PAGE_UP

public final static int SCROLL_PAGE_UP = 603
The user has pushed the "page up" area of a scroll bar.

WINDOW_DEICONIFY

public final static int WINDOW_DEICONIFY = 204
The user has asked the window manager to deiconify the window.

WINDOW_DESTROY

public final static int WINDOW_DESTROY = 201
The user has asked the window manager to kill the window.

WINDOW_EXPOSE

public final static int WINDOW_EXPOSE = 202
A window has becom exposed.

WINDOW_ICONIFY

public final static int WINDOW_ICONIFY = 203
The user has asked the window manager to iconify the window.

WINDOW_MOVED

public final static int WINDOW_MOVED = 205
The window has moved.

DOWN

public final static int DOWN = 1005
The down key.

END

public final static int END = 1001
The end key.

F1

public final static int F1 = 1008
The F1 function key.

F2

public final static int F2 = 1009
The F2 function key.

F3

public final static int F3 = 1010
The F3 function key.

F4

public final static int F4 = 1011
The F4 function key.

F5

public final static int F5 = 1012
The F5 function key.

F6

public final static int F6 = 1013
The F6 function key.

F7

public final static int F7 = 1014
The F7 function key.

F8

public final static int F8 = 1015
The F8 function key.

F9

public final static int F9 = 1016
The F9 function key.

F10

public final static int F10 = 1017
The F10 function key.

F11

public final static int F11 = 1018
The F11 function key.

F12

public final static int F12 = 1019
The F12 function key.

HOME

public final static int HOME = 1008
The home key.

LEFT

public final static int LEFT = 1006
The left arrow key.

PGDN

public final static int PGDN = 1003
The page down key.

PGUP

public final static int PGUP = 1002
The page up key.

RIGHT

public final static int RIGHT = 1007
The right arrow key.

UP

public final static int UP = 1004
The up arrow key.

ALT_MASK

public final static int ALT_MASK = 8
This flag indicates that the "alt" key was down when the event occurred. For mouse events, this flag indicates that the middle button was pressed or released.

CTRL_MASK

public final static int CTRL_MASK = 2
This flag indicates that the control key was down when the event occurred.

SHIFT_MASK

public final static int SHIFT_MASK = 0
This flag indicates that the shift key was down when the event occurred.

META_MASK

public final static int META_MASK = 4
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.

Constructors

Event

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

Event

public Event(Object target, long when, int id,
int x, int y, int key, int modifiers)
Creates 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, long when, int id, int x,
int y, int key, int modifiers, Object arg)
Creates 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

Methods

controlDown

public boolean controlDown()
Returns:
true if this event indicates that the control key was down; false otherwise.
See Also:
modifiers (II-§1.14.6)
shiftDown (II-§1.14.68)
metaDown (II-§1.14.66).

metaDown

public boolean metaDown()
Returns:
true if this event indicates that the meta key was down; false otherwise.
See Also:
modifiers (II-§1.14.6)
shiftDown (II-§1.14.68)
controlDown (II-§1.14.65).

paramString

protected String paramString()
Returns the parameter string representing this event. This string is useful for debugging.
Returns:
the parameter string of this event.

shiftDown

public boolean shiftDown()
Returns:
true if this event indicates that the shift key was down; false otherwise.
See Also:
modifiers (II-§1.14.6)
controlDown (II-§1.14.65)
metaDown (II-§1.14.66).

toString

public String toString()
Returns:
a string representation of this event.
Overrides:n
toString in class Object (I-§1.12.9).

translate

public void translate(int dx, int dy)
Translates this event so that its x and y position are increased by dx and dy respectively.
Parameters:
dX - the amount to translate the x coordinate
dY - the amount to translate the y coordinate

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com