Package java.awt |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
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.
public Object argAn arbitrary argument of the event. The value of this field depends on the type of event.
public int clickCountFor MOUSE_DOWN events, this field indicates the number of consecutive clicks. For other events, it is zero.
public Event evtThe next event. This field is set when putting events into a linked list.
public int idThe type of the event.
public int keyThe key that was pressed in a keyboard event.
public int modifiersThe state of the modifier keys.
public Object targetThe target component. This indicates the component over which the event occurred or with which the event is associated.
public long whenThe time stamp of the event.
public int xThe x coordinate of the event.
public int yThe y coordinate of the event.
public final static int ACTION_EVENT = 1001This event indicates that the user wants some action to occur.
public final static int GOT_FOCUS = 1004A component gained the focus.
public final static int KEY_ACTION = 403The user has pressed an "action" key. The key field contains one of the special values indicated in DOWN to UP.
public final static int KEY_ACTION_RELEASE = 404The user has released an "action" key. The key field contains one of the special values indicated in DOWN to UP.
public final static int KEY_PRESS = 401The user has pressed a normal key.
public final static int KEY_RELEASE = 402The user has released a normal key.
public final static int LIST_DESELECT = 702An item in a list has been deselected.
public final static int LIST_SELECT = 701An item in a list has been selected.
public final static int LOAD_FILE = 1002A file loading event.
public final static int LOST_FOCUS = 1005A component lost the focus.
public final static int MOUSE_DOWN = 501The 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.
public final static int MOUSE_DRAG = 506The 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.
public final static int MOUSE_ENTER = 504The mouse has entered a component.
public final static int MOUSE_EXIT = 505The mouse has exited a component.
public final static int MOUSE_MOVE = 503The mouse has moved with no button pressed.
public final static int MOUSE_UP = 502The 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.
public final static int SAVE_FILE = 1003A file saving event.
public final static int SCROLL_ABSOLUTE = 605The user has moved the bubble in a scroll bar.
public final static int SCROLL_LINE_DOWN = 602The user has pushed the "line down" area of a scroll bar.
public final static int SCROLL_LINE_UP = 601The user has pushed the "line up" area of a scroll bar.
public final static int SCROLL_PAGE_DOWN = 604The user has pushed the "page down" area of a scroll bar.
public final static int SCROLL_PAGE_UP = 603The user has pushed the "page up" area of a scroll bar.
public final static int WINDOW_DEICONIFY = 204The user has asked the window manager to deiconify the window.
public final static int WINDOW_DESTROY = 201The user has asked the window manager to kill the window.
public final static int WINDOW_EXPOSE = 202A window has becom exposed.
public final static int WINDOW_ICONIFY = 203The user has asked the window manager to iconify the window.
public final static int WINDOW_MOVED = 205The window has moved.
public final static int DOWN = 1005The down key.
public final static int END = 1001The end key.
public final static int F1 = 1008The F1 function key.
public final static int F2 = 1009The F2 function key.
public final static int F3 = 1010The F3 function key.
public final static int F4 = 1011The F4 function key.
public final static int F5 = 1012The F5 function key.
public final static int F6 = 1013The F6 function key.
public final static int F7 = 1014The F7 function key.
public final static int F8 = 1015The F8 function key.
public final static int F9 = 1016The F9 function key.
public final static int F10 = 1017The F10 function key.
public final static int F11 = 1018The F11 function key.
public final static int F12 = 1019The F12 function key.
public final static int HOME = 1008The home key.
public final static int LEFT = 1006The left arrow key.
public final static int PGDN = 1003The page down key.
public final static int PGUP = 1002The page up key.
public final static int RIGHT = 1007The right arrow key.
public final static int UP = 1004The up arrow key.
public final static int ALT_MASK = 8This 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.
public final static int CTRL_MASK = 2This flag indicates that the control key was down when the event occurred.
public final static int SHIFT_MASK = 0This flag indicates that the shift key was down when the event occurred.
public final static int META_MASK = 4This 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.
public Event(Object target, int id, Object arg)Creates an Event with the specified target component, event type, and argument.
Parameter Description target the target component id the event type arg the specified argument
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.
Parameter Description 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
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.
Parameter Description 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
public boolean controlDown()Return Value:
Returns true if this event indicates that the control key was down; false otherwise.
public boolean metaDown()Return Value:
Returns true if this event indicates that the meta key was down; false otherwise.
See Also: modifiers shiftDown controlDown .
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.
public boolean shiftDown()Return Value:
Returns true if this event indicates that the shift key was down; false otherwise.
See Also: modifiers controlDown metaDown .
public String toString()Return Value:
Returns a string representation of this event.
toString in class Object .
public void translate(int dx, int dy)Translates this event so that its x and y position are increased by dx and dy respectively.
Parameter Description dX the amount to translate the x coordinate dY the amount to translate the y coordinate