📄 event.java
字号:
/*
* @(#)Event.java 1.57 97/08/04
*
* Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* CopyrightVersion 1.1_beta
*
*/
package java.awt;
import java.awt.event.*;
import java.io.*;
/**
* <code>Event</code> is a platform-independent class that
* encapsulates events from the platform's Graphical User
* Interface in the Java 1.0 event model. In Java 1.1
* and later versions, the <code>Event</code> class is maintained
* only for backwards compatibilty. The information in this
* class description is provided to assist programmers in
* converting Java 1.0 programs to the new event model.
* <p>
* In the Java 1.0 event model, an event contains an
* <a href="#id"><code>id</code></a> field
* that indicates what type of event it is and which other
* <code>Event</code> variables are relevant for the event.
* <p>
* For keyboard events, <a href="#key"><code>key</code></a>
* contains a value indicating which key was activated, and
* <a href="#modifiers"><code>modifiers</code></a> contains the
* modifiers for that event. For the KEY_PRESS and KEY_RELEASE
* event ids, the value of <code>key</code> is the unicode
* character code for the key. For KEY_ACTION and
* KEY_ACTION_RELEASE, the value of <code>key</code> is
* one of the defined action-key identifiers in the
* <code>Event</code> class (<code>PGUP</code>,
* <code>PGDN</code>, <code>F1</code>, <code>F2</code>, etc).
*
* @version 1.57 08/04/97
* @author Sami Shaio
* @since JDK1.0
*/
public class Event implements java.io.Serializable {
private transient int data;
/* Modifier constants */
/**
* This flag indicates that the Shift key was down when the event
* occurred.
* @since JDK1.0
*/
public static final int SHIFT_MASK = 1 << 0;
/**
* This flag indicates that the Control key was down when the event
* occurred.
* @since JDK1.0
*/
public static final int CTRL_MASK = 1 << 1;
/**
* 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.
* @since JDK1.0
*/
public static final int META_MASK = 1 << 2;
/**
* This flag indicates that the Alt key was down when
* the event occurred. For mouse events, this flag indicates that the
* middle mouse button was pressed or released.
* @since JDK1.0
*/
public static final int ALT_MASK = 1 << 3;
/* Action keys */
/**
* The Home key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int HOME = 1000;
/**
* The End key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int END = 1001;
/**
* The Page Up key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int PGUP = 1002;
/**
* The Page Down key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int PGDN = 1003;
/**
* The Up Arrow key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int UP = 1004;
/**
* The Down Arrow key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int DOWN = 1005;
/**
* The Left Arrow key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int LEFT = 1006;
/**
* The Right Arrow key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int RIGHT = 1007;
/**
* The F1 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F1 = 1008;
/**
* The F2 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F2 = 1009;
/**
* The F3 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F3 = 1010;
/**
* The F4 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F4 = 1011;
/**
* The F5 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F5 = 1012;
/**
* The F6 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F6 = 1013;
/**
* The F7 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F7 = 1014;
/**
* The F8 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F8 = 1015;
/**
* The F9 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F9 = 1016;
/**
* The F10 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F10 = 1017;
/**
* The F11 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F11 = 1018;
/**
* The F12 function key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int F12 = 1019;
/**
* The Print Screen key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int PRINT_SCREEN = 1020;
/**
* The Scroll Lock key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int SCROLL_LOCK = 1021;
/**
* The Caps Lock key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int CAPS_LOCK = 1022;
/**
* The Num Lock key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int NUM_LOCK = 1023;
/**
* The Pause key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int PAUSE = 1024;
/**
* The Insert key, a non-ASCII action key.
* @since JDK1.0
*/
public static final int INSERT = 1025;
/* Non-action keys */
/**
* The Enter key.
* @since JDK1.0
*/
public static final int ENTER = '\n';
/**
* The BackSpace key.
* @since JDK1.0
*/
public static final int BACK_SPACE = '\b';
/**
* The Tab key.
* @since JDK1.0
*/
public static final int TAB = '\t';
/**
* The Escape key.
* @since JDK1.0
*/
public static final int ESCAPE = 27;
/**
* The Delete key.
* @since JDK1.0
*/
public static final int DELETE = 127;
/* Base for all window events. */
private static final int WINDOW_EVENT = 200;
/**
* The user has asked the window manager to kill the window.
* @since JDK1.0
*/
public static final int WINDOW_DESTROY = 1 + WINDOW_EVENT;
/**
* The user has asked the window manager to expose the window.
* @since JDK1.0
*/
public static final int WINDOW_EXPOSE = 2 + WINDOW_EVENT;
/**
* The user has asked the window manager to iconify the window.
* @since JDK1.0
*/
public static final int WINDOW_ICONIFY = 3 + WINDOW_EVENT;
/**
* The user has asked the window manager to de-iconify the window.
* @since JDK1.0
*/
public static final int WINDOW_DEICONIFY = 4 + WINDOW_EVENT;
/**
* The user has asked the window manager to move the window.
* @since JDK1.0
*/
public static final int WINDOW_MOVED = 5 + WINDOW_EVENT;
/* Base for all keyboard events. */
private static final int KEY_EVENT = 400;
/**
* The user has pressed a normal key.
* @since JDK1.0
*/
public static final int KEY_PRESS = 1 + KEY_EVENT;
/**
* The user has released a normal key.
* @since JDK1.0
*/
public static final int KEY_RELEASE = 2 + KEY_EVENT;
/**
* The user has pressed a non-ASCII <em>action</em> key.
* The <code>key</code> field contains a value that indicates
* that the event occurred on one of the action keys, which
* comprise the 12 function keys, the arrow (cursor) keys,
* Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
* Caps Lock, Num Lock, Pause, and Insert.
* @since JDK1.0
*/
public static final int KEY_ACTION = 3 + KEY_EVENT;
/**
* The user has released a non-ASCII <em>action</em> key.
* The <code>key</code> field contains a value that indicates
* that the event occurred on one of the action keys, which
* comprise the 12 function keys, the arrow (cursor) keys,
* Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
* Caps Lock, Num Lock, Pause, and Insert.
* @since JDK1.0
*/
public static final int KEY_ACTION_RELEASE = 4 + KEY_EVENT;
/* Base for all mouse events. */
private static final int MOUSE_EVENT = 500;
/**
* The user has pressed the mouse button. The <code>ALT_MASK</code>
* flag indicates that the middle button has been pressed.
* The <code>META_MASK</code>flag indicates that the
* right button has been pressed.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
* @since JDK1.0
*/
public static final int MOUSE_DOWN = 1 + MOUSE_EVENT;
/**
* The user has released the mouse button. The <code>ALT_MASK</code>
* flag indicates that the middle button has been released.
* The <code>META_MASK</code>flag indicates that the
* right button has been released.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
* @since JDK1.0
*/
public static final int MOUSE_UP = 2 + MOUSE_EVENT;
/**
* The mouse has moved with no button pressed.
* @since JDK1.0
*/
public static final int MOUSE_MOVE = 3 + MOUSE_EVENT;
/**
* The mouse has entered a component.
* @since JDK1.0
*/
public static final int MOUSE_ENTER = 4 + MOUSE_EVENT;
/**
* The mouse has exited a component.
* @since JDK1.0
*/
public static final int MOUSE_EXIT = 5 + MOUSE_EVENT;
/**
* The user has moved the mouse with a button pressed. The
* <code>ALT_MASK</code> flag indicates that the middle
* button is being pressed. The <code>META_MASK</code> flag indicates
* that the right button is being pressed.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
* @since JDK1.0
*/
public static final int MOUSE_DRAG = 6 + MOUSE_EVENT;
/* Scrolling events */
private static final int SCROLL_EVENT = 600;
/**
* The user has activated the <em>line up</em>
* area of a scroll bar.
* @since JDK1.0
*/
public static final int SCROLL_LINE_UP = 1 + SCROLL_EVENT;
/**
* The user has activated the <em>line down</em>
* area of a scroll bar.
* @since JDK1.0
*/
public static final int SCROLL_LINE_DOWN = 2 + SCROLL_EVENT;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -