Package java.awt Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class Event

Fields , Constructors , Methods

public  class  java.awt.Event
    extends  java.lang.Object  
{
        // Fields
    public Object arg;	
    public int clickCount;	
    public Event evt;	
    public int id;	
    public int key;	
    public int modifiers;	
    public Object target;	
    public long when;	
    public int x;	
    public int y;	

      // possible values for the id field	
    public final static int ACTION_EVENT;	
    public final static int GOT_FOCUS;	
    public final static int KEY_ACTION;	
    public final static int KEY_ACTION_RELEASE;	
    public final static int KEY_PRESS;	
    public final static int KEY_RELEASE;	
    public final static int LIST_DESELECT;	
    public final static int LIST_SELECT;	
    public final static int LOAD_FILE;	
    public final static int LOST_FOCUS;	
    public final static int MOUSE_DOWN;	
    public final static int MOUSE_DRAG;	
    public final static int MOUSE_ENTER;	
    public final static int MOUSE_EXIT;	
    public final static int MOUSE_MOVE;	
    public final static int MOUSE_UP;	
    public final static int SAVE_FILE;	
    public final static int SCROLL_ABSOLUTE;	
    public final static int SCROLL_LINE_DOWN;	
    public final static int SCROLL_LINE_UP;	
    public final static int SCROLL_PAGE_DOWN;	
    public final static int SCROLL_PAGE_UP;	
    public final static int WINDOW_DEICONIFY;	
    public final static int WINDOW_DESTROY;	
    public final static int WINDOW_EXPOSE;	
    public final static int WINDOW_ICONIFY;	
    public final static int WINDOW_MOVED;	

      // possible values for the key field when the
        // action is KEY_ACTION or KEY_ACTION_RELEASE	
    public final static int DOWN;	
    public final static int END;	
    public final static int F1;	
    public final static int F2;	
    public final static int F3;	
    public final static int F4;	
    public final static int F5;	
    public final static int F6;	
    public final static int F7;	
    public final static int F8;	
    public final static int F9;	
    public final static int F10;	
    public final static int F11;	
    public final static int F12;	
    public final static int HOME;	
    public final static int LEFT;	
    public final static int PGDN;	
    public final static int PGUP;	
    public final static int RIGHT;	
    public final static int UP;	

        // possible masks for the modifiers field 
    public final static int ALT_MASK	
    public final static int CTRL_MASK;	
    public final static int META_MASK;	
    public final static int SHIFT_MASK;	

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

        // Methods
    public boolean controlDown();	
    public boolean metaDown();	
    protected String paramString();	
    public boolean shiftDown();	
    public String toString();	
    public void translate(int  dX, int  dY);	
}

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 DOWN to UP.


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 DOWN to UP.


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 flag indicates that the middle button has been pushed. The META_MASK 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 flag indicates that the middle button is being pushed. The META_MASK 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 flag indicates that the middle button has been pushed. The META_MASK 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.

ParameterDescription
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.

ParameterDescription
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.

ParameterDescription
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() 

Return Value:

Returns true if this event indicates that the control key was down; false otherwise.

See Also: modifiers shiftDown metaDown .


metaDown

public boolean metaDown() 

Return Value:

Returns true if this event indicates that the meta key was down; false otherwise.

See Also: modifiers shiftDown controlDown .


paramString

protected String paramString() 

Returns the parameter string representing this event. This string is useful for debugging.

Return Value:

Returns the parameter string of this event.


shiftDown

public boolean shiftDown() 

Return Value:

Returns true if this event indicates that the shift key was down; false otherwise.

See Also: modifiers controlDown metaDown .


toString

public String toString() 

Return Value:

Returns a string representation of this event.

toString in class Object .


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.

ParameterDescription
dX the amount to translate the x coordinate
dY the amount to translate the y coordinate



Top© 1996 Sun Microsystems, Inc. All rights reserved.