0N/A/*
2362N/A * Copyright (c) 1995, 2002, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage java.awt;
0N/A
0N/Aimport java.awt.event.*;
0N/Aimport java.io.*;
0N/A
0N/A/**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * <code>Event</code> is a platform-independent class that
0N/A * encapsulates events from the platform's Graphical User
0N/A * Interface in the Java&nbsp;1.0 event model. In Java&nbsp;1.1
0N/A * and later versions, the <code>Event</code> class is maintained
0N/A * only for backwards compatibilty. The information in this
0N/A * class description is provided to assist programmers in
0N/A * converting Java&nbsp;1.0 programs to the new event model.
0N/A * <p>
0N/A * In the Java&nbsp;1.0 event model, an event contains an
0N/A * {@link Event#id} field
0N/A * that indicates what type of event it is and which other
0N/A * <code>Event</code> variables are relevant for the event.
0N/A * <p>
0N/A * For keyboard events, {@link Event#key}
0N/A * contains a value indicating which key was activated, and
0N/A * {@link Event#modifiers} contains the
0N/A * modifiers for that event. For the KEY_PRESS and KEY_RELEASE
0N/A * event ids, the value of <code>key</code> is the unicode
0N/A * character code for the key. For KEY_ACTION and
0N/A * KEY_ACTION_RELEASE, the value of <code>key</code> is
0N/A * one of the defined action-key identifiers in the
0N/A * <code>Event</code> class (<code>PGUP</code>,
0N/A * <code>PGDN</code>, <code>F1</code>, <code>F2</code>, etc).
0N/A *
0N/A * @author Sami Shaio
0N/A * @since JDK1.0
0N/A */
0N/Apublic class Event implements java.io.Serializable {
0N/A private transient long data;
0N/A
0N/A /* Modifier constants */
0N/A
0N/A /**
0N/A * This flag indicates that the Shift key was down when the event
0N/A * occurred.
0N/A */
0N/A public static final int SHIFT_MASK = 1 << 0;
0N/A
0N/A /**
0N/A * This flag indicates that the Control key was down when the event
0N/A * occurred.
0N/A */
0N/A public static final int CTRL_MASK = 1 << 1;
0N/A
0N/A /**
0N/A * This flag indicates that the Meta key was down when the event
0N/A * occurred. For mouse events, this flag indicates that the right
0N/A * button was pressed or released.
0N/A */
0N/A public static final int META_MASK = 1 << 2;
0N/A
0N/A /**
0N/A * This flag indicates that the Alt key was down when
0N/A * the event occurred. For mouse events, this flag indicates that the
0N/A * middle mouse button was pressed or released.
0N/A */
0N/A public static final int ALT_MASK = 1 << 3;
0N/A
0N/A /* Action keys */
0N/A
0N/A /**
0N/A * The Home key, a non-ASCII action key.
0N/A */
0N/A public static final int HOME = 1000;
0N/A
0N/A /**
0N/A * The End key, a non-ASCII action key.
0N/A */
0N/A public static final int END = 1001;
0N/A
0N/A /**
0N/A * The Page Up key, a non-ASCII action key.
0N/A */
0N/A public static final int PGUP = 1002;
0N/A
0N/A /**
0N/A * The Page Down key, a non-ASCII action key.
0N/A */
0N/A public static final int PGDN = 1003;
0N/A
0N/A /**
0N/A * The Up Arrow key, a non-ASCII action key.
0N/A */
0N/A public static final int UP = 1004;
0N/A
0N/A /**
0N/A * The Down Arrow key, a non-ASCII action key.
0N/A */
0N/A public static final int DOWN = 1005;
0N/A
0N/A /**
0N/A * The Left Arrow key, a non-ASCII action key.
0N/A */
0N/A public static final int LEFT = 1006;
0N/A
0N/A /**
0N/A * The Right Arrow key, a non-ASCII action key.
0N/A */
0N/A public static final int RIGHT = 1007;
0N/A
0N/A /**
0N/A * The F1 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F1 = 1008;
0N/A
0N/A /**
0N/A * The F2 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F2 = 1009;
0N/A
0N/A /**
0N/A * The F3 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F3 = 1010;
0N/A
0N/A /**
0N/A * The F4 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F4 = 1011;
0N/A
0N/A /**
0N/A * The F5 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F5 = 1012;
0N/A
0N/A /**
0N/A * The F6 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F6 = 1013;
0N/A
0N/A /**
0N/A * The F7 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F7 = 1014;
0N/A
0N/A /**
0N/A * The F8 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F8 = 1015;
0N/A
0N/A /**
0N/A * The F9 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F9 = 1016;
0N/A
0N/A /**
0N/A * The F10 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F10 = 1017;
0N/A
0N/A /**
0N/A * The F11 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F11 = 1018;
0N/A
0N/A /**
0N/A * The F12 function key, a non-ASCII action key.
0N/A */
0N/A public static final int F12 = 1019;
0N/A
0N/A /**
0N/A * The Print Screen key, a non-ASCII action key.
0N/A */
0N/A public static final int PRINT_SCREEN = 1020;
0N/A
0N/A /**
0N/A * The Scroll Lock key, a non-ASCII action key.
0N/A */
0N/A public static final int SCROLL_LOCK = 1021;
0N/A
0N/A /**
0N/A * The Caps Lock key, a non-ASCII action key.
0N/A */
0N/A public static final int CAPS_LOCK = 1022;
0N/A
0N/A /**
0N/A * The Num Lock key, a non-ASCII action key.
0N/A */
0N/A public static final int NUM_LOCK = 1023;
0N/A
0N/A /**
0N/A * The Pause key, a non-ASCII action key.
0N/A */
0N/A public static final int PAUSE = 1024;
0N/A
0N/A /**
0N/A * The Insert key, a non-ASCII action key.
0N/A */
0N/A public static final int INSERT = 1025;
0N/A
0N/A /* Non-action keys */
0N/A
0N/A /**
0N/A * The Enter key.
0N/A */
0N/A public static final int ENTER = '\n';
0N/A
0N/A /**
0N/A * The BackSpace key.
0N/A */
0N/A public static final int BACK_SPACE = '\b';
0N/A
0N/A /**
0N/A * The Tab key.
0N/A */
0N/A public static final int TAB = '\t';
0N/A
0N/A /**
0N/A * The Escape key.
0N/A */
0N/A public static final int ESCAPE = 27;
0N/A
0N/A /**
0N/A * The Delete key.
0N/A */
0N/A public static final int DELETE = 127;
0N/A
0N/A
0N/A /* Base for all window events. */
0N/A private static final int WINDOW_EVENT = 200;
0N/A
0N/A /**
0N/A * The user has asked the window manager to kill the window.
0N/A */
0N/A public static final int WINDOW_DESTROY = 1 + WINDOW_EVENT;
0N/A
0N/A /**
0N/A * The user has asked the window manager to expose the window.
0N/A */
0N/A public static final int WINDOW_EXPOSE = 2 + WINDOW_EVENT;
0N/A
0N/A /**
0N/A * The user has asked the window manager to iconify the window.
0N/A */
0N/A public static final int WINDOW_ICONIFY = 3 + WINDOW_EVENT;
0N/A
0N/A /**
0N/A * The user has asked the window manager to de-iconify the window.
0N/A */
0N/A public static final int WINDOW_DEICONIFY = 4 + WINDOW_EVENT;
0N/A
0N/A /**
0N/A * The user has asked the window manager to move the window.
0N/A */
0N/A public static final int WINDOW_MOVED = 5 + WINDOW_EVENT;
0N/A
0N/A /* Base for all keyboard events. */
0N/A private static final int KEY_EVENT = 400;
0N/A
0N/A /**
0N/A * The user has pressed a normal key.
0N/A */
0N/A public static final int KEY_PRESS = 1 + KEY_EVENT;
0N/A
0N/A /**
0N/A * The user has released a normal key.
0N/A */
0N/A public static final int KEY_RELEASE = 2 + KEY_EVENT;
0N/A
0N/A /**
0N/A * The user has pressed a non-ASCII <em>action</em> key.
0N/A * The <code>key</code> field contains a value that indicates
0N/A * that the event occurred on one of the action keys, which
0N/A * comprise the 12 function keys, the arrow (cursor) keys,
0N/A * Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
0N/A * Caps Lock, Num Lock, Pause, and Insert.
0N/A */
0N/A public static final int KEY_ACTION = 3 + KEY_EVENT;
0N/A
0N/A /**
0N/A * The user has released a non-ASCII <em>action</em> key.
0N/A * The <code>key</code> field contains a value that indicates
0N/A * that the event occurred on one of the action keys, which
0N/A * comprise the 12 function keys, the arrow (cursor) keys,
0N/A * Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
0N/A * Caps Lock, Num Lock, Pause, and Insert.
0N/A */
0N/A public static final int KEY_ACTION_RELEASE = 4 + KEY_EVENT;
0N/A
0N/A /* Base for all mouse events. */
0N/A private static final int MOUSE_EVENT = 500;
0N/A
0N/A /**
0N/A * The user has pressed the mouse button. The <code>ALT_MASK</code>
0N/A * flag indicates that the middle button has been pressed.
0N/A * The <code>META_MASK</code>flag indicates that the
0N/A * right button has been pressed.
0N/A * @see java.awt.Event#ALT_MASK
0N/A * @see java.awt.Event#META_MASK
0N/A */
0N/A public static final int MOUSE_DOWN = 1 + MOUSE_EVENT;
0N/A
0N/A /**
0N/A * The user has released the mouse button. The <code>ALT_MASK</code>
0N/A * flag indicates that the middle button has been released.
0N/A * The <code>META_MASK</code>flag indicates that the
0N/A * right button has been released.
0N/A * @see java.awt.Event#ALT_MASK
0N/A * @see java.awt.Event#META_MASK
0N/A */
0N/A public static final int MOUSE_UP = 2 + MOUSE_EVENT;
0N/A
0N/A /**
0N/A * The mouse has moved with no button pressed.
0N/A */
0N/A public static final int MOUSE_MOVE = 3 + MOUSE_EVENT;
0N/A
0N/A /**
0N/A * The mouse has entered a component.
0N/A */
0N/A public static final int MOUSE_ENTER = 4 + MOUSE_EVENT;
0N/A
0N/A /**
0N/A * The mouse has exited a component.
0N/A */
0N/A public static final int MOUSE_EXIT = 5 + MOUSE_EVENT;
0N/A
0N/A /**
0N/A * The user has moved the mouse with a button pressed. The
0N/A * <code>ALT_MASK</code> flag indicates that the middle
0N/A * button is being pressed. The <code>META_MASK</code> flag indicates
0N/A * that the right button is being pressed.
0N/A * @see java.awt.Event#ALT_MASK
0N/A * @see java.awt.Event#META_MASK
0N/A */
0N/A public static final int MOUSE_DRAG = 6 + MOUSE_EVENT;
0N/A
0N/A
0N/A /* Scrolling events */
0N/A private static final int SCROLL_EVENT = 600;
0N/A
0N/A /**
0N/A * The user has activated the <em>line up</em>
0N/A * area of a scroll bar.
0N/A */
0N/A public static final int SCROLL_LINE_UP = 1 + SCROLL_EVENT;
0N/A
0N/A /**
0N/A * The user has activated the <em>line down</em>
0N/A * area of a scroll bar.
0N/A */
0N/A public static final int SCROLL_LINE_DOWN = 2 + SCROLL_EVENT;
0N/A
0N/A /**
0N/A * The user has activated the <em>page up</em>
0N/A * area of a scroll bar.
0N/A */
0N/A public static final int SCROLL_PAGE_UP = 3 + SCROLL_EVENT;
0N/A
0N/A /**
0N/A * The user has activated the <em>page down</em>
0N/A * area of a scroll bar.
0N/A */
0N/A public static final int SCROLL_PAGE_DOWN = 4 + SCROLL_EVENT;
0N/A
0N/A /**
0N/A * The user has moved the bubble (thumb) in a scroll bar,
0N/A * moving to an "absolute" position, rather than to
0N/A * an offset from the last postion.
0N/A */
0N/A public static final int SCROLL_ABSOLUTE = 5 + SCROLL_EVENT;
0N/A
0N/A /**
0N/A * The scroll begin event.
0N/A */
0N/A public static final int SCROLL_BEGIN = 6 + SCROLL_EVENT;
0N/A
0N/A /**
0N/A * The scroll end event.
0N/A */
0N/A public static final int SCROLL_END = 7 + SCROLL_EVENT;
0N/A
0N/A /* List Events */
0N/A private static final int LIST_EVENT = 700;
0N/A
0N/A /**
0N/A * An item in a list has been selected.
0N/A */
0N/A public static final int LIST_SELECT = 1 + LIST_EVENT;
0N/A
0N/A /**
0N/A * An item in a list has been deselected.
0N/A */
0N/A public static final int LIST_DESELECT = 2 + LIST_EVENT;
0N/A
0N/A /* Misc Event */
0N/A private static final int MISC_EVENT = 1000;
0N/A
0N/A /**
0N/A * This event indicates that the user wants some action to occur.
0N/A */
0N/A public static final int ACTION_EVENT = 1 + MISC_EVENT;
0N/A
0N/A /**
0N/A * A file loading event.
0N/A */
0N/A public static final int LOAD_FILE = 2 + MISC_EVENT;
0N/A
0N/A /**
0N/A * A file saving event.
0N/A */
0N/A public static final int SAVE_FILE = 3 + MISC_EVENT;
0N/A
0N/A /**
0N/A * A component gained the focus.
0N/A */
0N/A public static final int GOT_FOCUS = 4 + MISC_EVENT;
0N/A
0N/A /**
0N/A * A component lost the focus.
0N/A */
0N/A public static final int LOST_FOCUS = 5 + MISC_EVENT;
0N/A
0N/A /**
0N/A * The target component. This indicates the component over which the
0N/A * event occurred or with which the event is associated.
0N/A * This object has been replaced by AWTEvent.getSource()
0N/A *
0N/A * @serial
0N/A * @see java.awt.AWTEvent#getSource()
0N/A */
0N/A public Object target;
0N/A
0N/A /**
0N/A * The time stamp.
0N/A * Replaced by InputEvent.getWhen().
0N/A *
0N/A * @serial
0N/A * @see java.awt.event.InputEvent#getWhen()
0N/A */
0N/A public long when;
0N/A
0N/A /**
0N/A * Indicates which type of event the event is, and which
0N/A * other <code>Event</code> variables are relevant for the event.
0N/A * This has been replaced by AWTEvent.getID()
0N/A *
0N/A * @serial
0N/A * @see java.awt.AWTEvent#getID()
0N/A */
0N/A public int id;
0N/A
0N/A /**
0N/A * The <i>x</i> coordinate of the event.
0N/A * Replaced by MouseEvent.getX()
0N/A *
0N/A * @serial
0N/A * @see java.awt.event.MouseEvent#getX()
0N/A */
0N/A public int x;
0N/A
0N/A /**
0N/A * The <i>y</i> coordinate of the event.
0N/A * Replaced by MouseEvent.getY()
0N/A *
0N/A * @serial
0N/A * @see java.awt.event.MouseEvent#getY()
0N/A */
0N/A public int y;
0N/A
0N/A /**
0N/A * The key code of the key that was pressed in a keyboard event.
0N/A * This has been replaced by KeyEvent.getKeyCode()
0N/A *
0N/A * @serial
0N/A * @see java.awt.event.KeyEvent#getKeyCode()
0N/A */
0N/A public int key;
0N/A
0N/A /**
0N/A * The key character that was pressed in a keyboard event.
0N/A */
0N/A// public char keyChar;
0N/A
0N/A /**
0N/A * The state of the modifier keys.
0N/A * This is replaced with InputEvent.getModifiers()
0N/A * In java 1.1 MouseEvent and KeyEvent are subclasses
0N/A * of InputEvent.
0N/A *
0N/A * @serial
0N/A * @see java.awt.event.InputEvent#getModifiers()
0N/A */
0N/A public int modifiers;
0N/A
0N/A /**
0N/A * For <code>MOUSE_DOWN</code> events, this field indicates the
0N/A * number of consecutive clicks. For other events, its value is
0N/A * <code>0</code>.
0N/A * This field has been replaced by MouseEvent.getClickCount().
0N/A *
0N/A * @serial
0N/A * @see java.awt.event.MouseEvent#getClickCount().
0N/A */
0N/A public int clickCount;
0N/A
0N/A /**
0N/A * An arbitrary argument of the event. The value of this field
0N/A * depends on the type of event.
0N/A * <code>arg</code> has been replaced by event specific property.
0N/A *
0N/A * @serial
0N/A */
0N/A public Object arg;
0N/A
0N/A /**
0N/A * The next event. This field is set when putting events into a
0N/A * linked list.
0N/A * This has been replaced by EventQueue.
0N/A *
0N/A * @serial
0N/A * @see java.awt.EventQueue
0N/A */
0N/A public Event evt;
0N/A
0N/A /* table for mapping old Event action keys to KeyEvent virtual keys. */
0N/A private static final int actionKeyCodes[][] = {
0N/A /* virtual key action key */
0N/A { KeyEvent.VK_HOME, Event.HOME },
0N/A { KeyEvent.VK_END, Event.END },
0N/A { KeyEvent.VK_PAGE_UP, Event.PGUP },
0N/A { KeyEvent.VK_PAGE_DOWN, Event.PGDN },
0N/A { KeyEvent.VK_UP, Event.UP },
0N/A { KeyEvent.VK_DOWN, Event.DOWN },
0N/A { KeyEvent.VK_LEFT, Event.LEFT },
0N/A { KeyEvent.VK_RIGHT, Event.RIGHT },
0N/A { KeyEvent.VK_F1, Event.F1 },
0N/A { KeyEvent.VK_F2, Event.F2 },
0N/A { KeyEvent.VK_F3, Event.F3 },
0N/A { KeyEvent.VK_F4, Event.F4 },
0N/A { KeyEvent.VK_F5, Event.F5 },
0N/A { KeyEvent.VK_F6, Event.F6 },
0N/A { KeyEvent.VK_F7, Event.F7 },
0N/A { KeyEvent.VK_F8, Event.F8 },
0N/A { KeyEvent.VK_F9, Event.F9 },
0N/A { KeyEvent.VK_F10, Event.F10 },
0N/A { KeyEvent.VK_F11, Event.F11 },
0N/A { KeyEvent.VK_F12, Event.F12 },
0N/A { KeyEvent.VK_PRINTSCREEN, Event.PRINT_SCREEN },
0N/A { KeyEvent.VK_SCROLL_LOCK, Event.SCROLL_LOCK },
0N/A { KeyEvent.VK_CAPS_LOCK, Event.CAPS_LOCK },
0N/A { KeyEvent.VK_NUM_LOCK, Event.NUM_LOCK },
0N/A { KeyEvent.VK_PAUSE, Event.PAUSE },
0N/A { KeyEvent.VK_INSERT, Event.INSERT }
0N/A };
0N/A
0N/A /**
0N/A * This field controls whether or not the event is sent back
0N/A * down to the peer once the target has processed it -
0N/A * false means it's sent to the peer, true means it's not.
0N/A *
0N/A * @serial
0N/A * @see #isConsumed()
0N/A */
0N/A private boolean consumed = false;
0N/A
0N/A /*
0N/A * JDK 1.1 serialVersionUID
0N/A */
0N/A private static final long serialVersionUID = 5488922509400504703L;
0N/A
0N/A static {
0N/A /* ensure that the necessary native libraries are loaded */
0N/A Toolkit.loadLibraries();
0N/A if (!GraphicsEnvironment.isHeadless()) {
0N/A initIDs();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Initialize JNI field and method IDs for fields that may be
0N/A accessed from C.
0N/A */
0N/A private static native void initIDs();
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Creates an instance of <code>Event</code> with the specified target
0N/A * component, time stamp, event type, <i>x</i> and <i>y</i>
0N/A * coordinates, keyboard key, state of the modifier keys, and
0N/A * argument.
0N/A * @param target the target component.
0N/A * @param when the time stamp.
0N/A * @param id the event type.
0N/A * @param x the <i>x</i> coordinate.
0N/A * @param y the <i>y</i> coordinate.
0N/A * @param key the key pressed in a keyboard event.
0N/A * @param modifiers the state of the modifier keys.
0N/A * @param arg the specified argument.
0N/A */
0N/A public Event(Object target, long when, int id, int x, int y, int key,
0N/A int modifiers, Object arg) {
0N/A this.target = target;
0N/A this.when = when;
0N/A this.id = id;
0N/A this.x = x;
0N/A this.y = y;
0N/A this.key = key;
0N/A this.modifiers = modifiers;
0N/A this.arg = arg;
0N/A this.data = 0;
0N/A this.clickCount = 0;
0N/A switch(id) {
0N/A case ACTION_EVENT:
0N/A case WINDOW_DESTROY:
0N/A case WINDOW_ICONIFY:
0N/A case WINDOW_DEICONIFY:
0N/A case WINDOW_MOVED:
0N/A case SCROLL_LINE_UP:
0N/A case SCROLL_LINE_DOWN:
0N/A case SCROLL_PAGE_UP:
0N/A case SCROLL_PAGE_DOWN:
0N/A case SCROLL_ABSOLUTE:
0N/A case SCROLL_BEGIN:
0N/A case SCROLL_END:
0N/A case LIST_SELECT:
0N/A case LIST_DESELECT:
0N/A consumed = true; // these types are not passed back to peer
0N/A break;
0N/A default:
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Creates an instance of <code>Event</code>, with the specified target
0N/A * component, time stamp, event type, <i>x</i> and <i>y</i>
0N/A * coordinates, keyboard key, state of the modifier keys, and an
0N/A * argument set to <code>null</code>.
0N/A * @param target the target component.
0N/A * @param when the time stamp.
0N/A * @param id the event type.
0N/A * @param x the <i>x</i> coordinate.
0N/A * @param y the <i>y</i> coordinate.
0N/A * @param key the key pressed in a keyboard event.
0N/A * @param modifiers the state of the modifier keys.
0N/A */
0N/A public Event(Object target, long when, int id, int x, int y, int key, int modifiers) {
0N/A this(target, when, id, x, y, key, modifiers, null);
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Creates an instance of <code>Event</code> with the specified
0N/A * target component, event type, and argument.
0N/A * @param target the target component.
0N/A * @param id the event type.
0N/A * @param arg the specified argument.
0N/A */
0N/A public Event(Object target, int id, Object arg) {
0N/A this(target, 0, id, 0, 0, 0, 0, arg);
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Translates this event so that its <i>x</i> and <i>y</i>
0N/A * coordinates are increased by <i>dx</i> and <i>dy</i>,
0N/A * respectively.
0N/A * <p>
0N/A * This method translates an event relative to the given component.
0N/A * This involves, at a minimum, translating the coordinates into the
0N/A * local coordinate system of the given component. It may also involve
0N/A * translating a region in the case of an expose event.
0N/A * @param dx the distance to translate the <i>x</i> coordinate.
0N/A * @param dy the distance to translate the <i>y</i> coordinate.
0N/A */
0N/A public void translate(int dx, int dy) {
0N/A this.x += dx;
0N/A this.y += dy;
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Checks if the Shift key is down.
0N/A * @return <code>true</code> if the key is down;
0N/A * <code>false</code> otherwise.
0N/A * @see java.awt.Event#modifiers
0N/A * @see java.awt.Event#controlDown
0N/A * @see java.awt.Event#metaDown
0N/A */
0N/A public boolean shiftDown() {
0N/A return (modifiers & SHIFT_MASK) != 0;
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Checks if the Control key is down.
0N/A * @return <code>true</code> if the key is down;
0N/A * <code>false</code> otherwise.
0N/A * @see java.awt.Event#modifiers
0N/A * @see java.awt.Event#shiftDown
0N/A * @see java.awt.Event#metaDown
0N/A */
0N/A public boolean controlDown() {
0N/A return (modifiers & CTRL_MASK) != 0;
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Checks if the Meta key is down.
0N/A *
0N/A * @return <code>true</code> if the key is down;
0N/A * <code>false</code> otherwise.
0N/A * @see java.awt.Event#modifiers
0N/A * @see java.awt.Event#shiftDown
0N/A * @see java.awt.Event#controlDown
0N/A */
0N/A public boolean metaDown() {
0N/A return (modifiers & META_MASK) != 0;
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A */
0N/A void consume() {
0N/A switch(id) {
0N/A case KEY_PRESS:
0N/A case KEY_RELEASE:
0N/A case KEY_ACTION:
0N/A case KEY_ACTION_RELEASE:
0N/A consumed = true;
0N/A break;
0N/A default:
0N/A // event type cannot be consumed
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A */
0N/A boolean isConsumed() {
0N/A return consumed;
0N/A }
0N/A
0N/A /*
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Returns the integer key-code associated with the key in this event,
0N/A * as described in java.awt.Event.
0N/A */
0N/A static int getOldEventKey(KeyEvent e) {
0N/A int keyCode = e.getKeyCode();
0N/A for (int i = 0; i < actionKeyCodes.length; i++) {
0N/A if (actionKeyCodes[i][0] == keyCode) {
0N/A return actionKeyCodes[i][1];
0N/A }
0N/A }
0N/A return (int)e.getKeyChar();
0N/A }
0N/A
0N/A /*
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Returns a new KeyEvent char which corresponds to the int key
0N/A * of this old event.
0N/A */
0N/A char getKeyEventChar() {
0N/A for (int i = 0; i < actionKeyCodes.length; i++) {
0N/A if (actionKeyCodes[i][1] == key) {
0N/A return KeyEvent.CHAR_UNDEFINED;
0N/A }
0N/A }
0N/A return (char)key;
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Returns a string representing the state of this <code>Event</code>.
0N/A * This method is intended to be used only for debugging purposes, and the
0N/A * content and format of the returned string may vary between
0N/A * implementations. The returned string may be empty but may not be
0N/A * <code>null</code>.
0N/A *
0N/A * @return the parameter string of this event
0N/A */
0N/A protected String paramString() {
0N/A String str = "id=" + id + ",x=" + x + ",y=" + y;
0N/A if (key != 0) {
0N/A str += ",key=" + key;
0N/A }
0N/A if (shiftDown()) {
0N/A str += ",shift";
0N/A }
0N/A if (controlDown()) {
0N/A str += ",control";
0N/A }
0N/A if (metaDown()) {
0N/A str += ",meta";
0N/A }
0N/A if (target != null) {
0N/A str += ",target=" + target;
0N/A }
0N/A if (arg != null) {
0N/A str += ",arg=" + arg;
0N/A }
0N/A return str;
0N/A }
0N/A
0N/A /**
0N/A * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
0N/A * available only for backwards compatilibility. It has been replaced
0N/A * by the <code>AWTEvent</code> class and its subclasses.
0N/A * <p>
0N/A * Returns a representation of this event's values as a string.
0N/A * @return a string that represents the event and the values
0N/A * of its member fields.
0N/A * @see java.awt.Event#paramString
0N/A * @since JDK1.1
0N/A */
0N/A public String toString() {
0N/A return getClass().getName() + "[" + paramString() + "]";
0N/A }
0N/A}