jdk/src/java.desktop/share/classes/java/awt/Event.java
author serb
Tue, 31 Jan 2017 19:22:35 +0300
changeset 43722 25ba19c20260
parent 35667 ed476aba94de
permissions -rw-r--r--
8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK Reviewed-by: prr, alexsch, azvegint, mchung, egahlin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
43722
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 35667
diff changeset
     2
 * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
43722
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 35667
diff changeset
    27
import java.awt.event.KeyEvent;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    30
 * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
    31
 * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    32
 * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    34
 * {@code Event} is a platform-independent class that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * encapsulates events from the platform's Graphical User
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Interface in the Java&nbsp;1.0 event model. In Java&nbsp;1.1
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    37
 * and later versions, the {@code Event} class is maintained
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
    38
 * only for backwards compatibility. The information in this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * class description is provided to assist programmers in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * converting Java&nbsp;1.0 programs to the new event model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * In the Java&nbsp;1.0 event model, an event contains an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * {@link Event#id} field
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * that indicates what type of event it is and which other
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    45
 * {@code Event} variables are relevant for the event.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * For keyboard events, {@link Event#key}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * contains a value indicating which key was activated, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * {@link Event#modifiers} contains the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * modifiers for that event.  For the KEY_PRESS and KEY_RELEASE
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    51
 * event ids, the value of {@code key} is the unicode
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * character code for the key. For KEY_ACTION and
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    53
 * KEY_ACTION_RELEASE, the value of {@code key} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * one of the defined action-key identifiers in the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    55
 * {@code Event} class ({@code PGUP},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    56
 * {@code PGDN}, {@code F1}, {@code F2}, etc).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
43722
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 35667
diff changeset
    58
 * @deprecated It is recommended that {@code AWTEvent} and its subclasses be
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 35667
diff changeset
    59
 *             used instead
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @author     Sami Shaio
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
    61
 * @since      1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 */
43722
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 35667
diff changeset
    63
@Deprecated(since = "9")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
public class Event implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private transient long data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /* Modifier constants */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * This flag indicates that the Shift key was down when the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static final int SHIFT_MASK          = 1 << 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * This flag indicates that the Control key was down when the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public static final int CTRL_MASK           = 1 << 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * This flag indicates that the Meta key was down when the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * occurred. For mouse events, this flag indicates that the right
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * button was pressed or released.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public static final int META_MASK           = 1 << 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * This flag indicates that the Alt key was down when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * the event occurred. For mouse events, this flag indicates that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * middle mouse button was pressed or released.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public static final int ALT_MASK            = 1 << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /* Action keys */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * The Home key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public static final int HOME                = 1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * The End key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public static final int END                 = 1001;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * The Page Up key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public static final int PGUP                = 1002;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * The Page Down key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public static final int PGDN                = 1003;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * The Up Arrow key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public static final int UP                  = 1004;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * The Down Arrow key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public static final int DOWN                = 1005;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * The Left Arrow key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public static final int LEFT                = 1006;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * The Right Arrow key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public static final int RIGHT               = 1007;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * The F1 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public static final int F1                  = 1008;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * The F2 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public static final int F2                  = 1009;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * The F3 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public static final int F3                  = 1010;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * The F4 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public static final int F4                  = 1011;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * The F5 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public static final int F5                  = 1012;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * The F6 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public static final int F6                  = 1013;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * The F7 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public static final int F7                  = 1014;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * The F8 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public static final int F8                  = 1015;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * The F9 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public static final int F9                  = 1016;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * The F10 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public static final int F10                 = 1017;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * The F11 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public static final int F11                 = 1018;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * The F12 function key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public static final int F12                 = 1019;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * The Print Screen key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public static final int PRINT_SCREEN        = 1020;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * The Scroll Lock key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public static final int SCROLL_LOCK         = 1021;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * The Caps Lock key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public static final int CAPS_LOCK           = 1022;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * The Num Lock key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    public static final int NUM_LOCK            = 1023;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * The Pause key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public static final int PAUSE               = 1024;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * The Insert key, a non-ASCII action key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    public static final int INSERT              = 1025;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    /* Non-action keys */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * The Enter key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public static final int ENTER               = '\n';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * The BackSpace key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public static final int BACK_SPACE          = '\b';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * The Tab key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public static final int TAB                 = '\t';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * The Escape key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    public static final int ESCAPE              = 27;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * The Delete key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public static final int DELETE              = 127;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /* Base for all window events. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    private static final int WINDOW_EVENT       = 200;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * The user has asked the window manager to kill the window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public static final int WINDOW_DESTROY      = 1 + WINDOW_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * The user has asked the window manager to expose the window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public static final int WINDOW_EXPOSE       = 2 + WINDOW_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * The user has asked the window manager to iconify the window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public static final int WINDOW_ICONIFY      = 3 + WINDOW_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * The user has asked the window manager to de-iconify the window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    public static final int WINDOW_DEICONIFY    = 4 + WINDOW_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * The user has asked the window manager to move the window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public static final int WINDOW_MOVED        = 5 + WINDOW_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    /* Base for all keyboard events. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    private static final int KEY_EVENT          = 400;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * The user has pressed a normal key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    public static final int KEY_PRESS           = 1 + KEY_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * The user has released a normal key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public static final int KEY_RELEASE         = 2 + KEY_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * The user has pressed a non-ASCII <em>action</em> key.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   298
     * The {@code key} field contains a value that indicates
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * that the event occurred on one of the action keys, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * comprise the 12 function keys, the arrow (cursor) keys,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Caps Lock, Num Lock, Pause, and Insert.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public static final int KEY_ACTION          = 3 + KEY_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * The user has released a non-ASCII <em>action</em> key.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   308
     * The {@code key} field contains a value that indicates
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * that the event occurred on one of the action keys, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * comprise the 12 function keys, the arrow (cursor) keys,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * Caps Lock, Num Lock, Pause, and Insert.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    public static final int KEY_ACTION_RELEASE  = 4 + KEY_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /* Base for all mouse events. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    private static final int MOUSE_EVENT        = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   320
     * The user has pressed the mouse button. The {@code ALT_MASK}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * flag indicates that the middle button has been pressed.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   322
     * The {@code META_MASK} flag indicates that the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * right button has been pressed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @see     java.awt.Event#ALT_MASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @see     java.awt.Event#META_MASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public static final int MOUSE_DOWN          = 1 + MOUSE_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   330
     * The user has released the mouse button. The {@code ALT_MASK}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * flag indicates that the middle button has been released.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   332
     * The {@code META_MASK} flag indicates that the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * right button has been released.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @see     java.awt.Event#ALT_MASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @see     java.awt.Event#META_MASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    public static final int MOUSE_UP            = 2 + MOUSE_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * The mouse has moved with no button pressed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    public static final int MOUSE_MOVE          = 3 + MOUSE_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * The mouse has entered a component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    public static final int MOUSE_ENTER         = 4 + MOUSE_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * The mouse has exited a component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    public static final int MOUSE_EXIT          = 5 + MOUSE_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * The user has moved the mouse with a button pressed. The
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   356
     * {@code ALT_MASK} flag indicates that the middle
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   357
     * button is being pressed. The {@code META_MASK} flag indicates
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * that the right button is being pressed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @see     java.awt.Event#ALT_MASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @see     java.awt.Event#META_MASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    public static final int MOUSE_DRAG          = 6 + MOUSE_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /* Scrolling events */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    private static final int SCROLL_EVENT       = 600;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * The user has activated the <em>line up</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * area of a scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public static final int SCROLL_LINE_UP      = 1 + SCROLL_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * The user has activated the <em>line down</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * area of a scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public static final int SCROLL_LINE_DOWN    = 2 + SCROLL_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * The user has activated the <em>page up</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * area of a scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    public static final int SCROLL_PAGE_UP      = 3 + SCROLL_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * The user has activated the <em>page down</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * area of a scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    public static final int SCROLL_PAGE_DOWN    = 4 + SCROLL_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * The user has moved the bubble (thumb) in a scroll bar,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * moving to an "absolute" position, rather than to
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   395
     * an offset from the last position.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    public static final int SCROLL_ABSOLUTE     = 5 + SCROLL_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * The scroll begin event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    public static final int SCROLL_BEGIN        = 6 + SCROLL_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * The scroll end event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    public static final int SCROLL_END          = 7 + SCROLL_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /* List Events */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    private static final int LIST_EVENT         = 700;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * An item in a list has been selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public static final int LIST_SELECT         = 1 + LIST_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * An item in a list has been deselected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public static final int LIST_DESELECT       = 2 + LIST_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    /* Misc Event */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    private static final int MISC_EVENT         = 1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * This event indicates that the user wants some action to occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    public static final int ACTION_EVENT        = 1 + MISC_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * A file loading event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    public static final int LOAD_FILE           = 2 + MISC_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * A file saving event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public static final int SAVE_FILE           = 3 + MISC_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * A component gained the focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    public static final int GOT_FOCUS           = 4 + MISC_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * A component lost the focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    public static final int LOST_FOCUS          = 5 + MISC_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * The target component. This indicates the component over which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * event occurred or with which the event is associated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * This object has been replaced by AWTEvent.getSource()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @see java.awt.AWTEvent#getSource()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public Object target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * The time stamp.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * Replaced by InputEvent.getWhen().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @see java.awt.event.InputEvent#getWhen()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    public long when;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * Indicates which type of event the event is, and which
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   471
     * other {@code Event} variables are relevant for the event.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * This has been replaced by AWTEvent.getID()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * @see java.awt.AWTEvent#getID()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    public int id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * The <i>x</i> coordinate of the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * Replaced by MouseEvent.getX()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @see java.awt.event.MouseEvent#getX()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    public int x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * The <i>y</i> coordinate of the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * Replaced by MouseEvent.getY()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @see java.awt.event.MouseEvent#getY()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    public int y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * The key code of the key that was pressed in a keyboard event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * This has been replaced by KeyEvent.getKeyCode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @see java.awt.event.KeyEvent#getKeyCode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    public int key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * The key character that was pressed in a keyboard event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
//    public char keyChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * The state of the modifier keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * This is replaced with InputEvent.getModifiers()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * In java 1.1 MouseEvent and KeyEvent are subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * of InputEvent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @see java.awt.event.InputEvent#getModifiers()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    public int modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   523
     * For {@code MOUSE_DOWN} events, this field indicates the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * number of consecutive clicks. For other events, its value is
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   525
     * {@code 0}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * This field has been replaced by MouseEvent.getClickCount().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * @serial
20172
f48935a247ec 8025218: [javadoc] some errors in java/awt classes
yan
parents: 5506
diff changeset
   529
     * @see java.awt.event.MouseEvent#getClickCount()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    public int clickCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * An arbitrary argument of the event. The value of this field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * depends on the type of event.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   536
     * {@code arg} has been replaced by event specific property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    public Object arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * The next event. This field is set when putting events into a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * linked list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * This has been replaced by EventQueue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * @see java.awt.EventQueue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    public Event evt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    /* table for mapping old Event action keys to KeyEvent virtual keys. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    private static final int actionKeyCodes[][] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    /*    virtual key              action key   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        { KeyEvent.VK_HOME,        Event.HOME         },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        { KeyEvent.VK_END,         Event.END          },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        { KeyEvent.VK_PAGE_UP,     Event.PGUP         },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        { KeyEvent.VK_PAGE_DOWN,   Event.PGDN         },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        { KeyEvent.VK_UP,          Event.UP           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        { KeyEvent.VK_DOWN,        Event.DOWN         },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        { KeyEvent.VK_LEFT,        Event.LEFT         },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        { KeyEvent.VK_RIGHT,       Event.RIGHT        },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        { KeyEvent.VK_F1,          Event.F1           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        { KeyEvent.VK_F2,          Event.F2           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        { KeyEvent.VK_F3,          Event.F3           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        { KeyEvent.VK_F4,          Event.F4           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        { KeyEvent.VK_F5,          Event.F5           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        { KeyEvent.VK_F6,          Event.F6           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        { KeyEvent.VK_F7,          Event.F7           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        { KeyEvent.VK_F8,          Event.F8           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        { KeyEvent.VK_F9,          Event.F9           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        { KeyEvent.VK_F10,         Event.F10          },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        { KeyEvent.VK_F11,         Event.F11          },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        { KeyEvent.VK_F12,         Event.F12          },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        { KeyEvent.VK_PRINTSCREEN, Event.PRINT_SCREEN },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        { KeyEvent.VK_SCROLL_LOCK, Event.SCROLL_LOCK  },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        { KeyEvent.VK_CAPS_LOCK,   Event.CAPS_LOCK    },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        { KeyEvent.VK_NUM_LOCK,    Event.NUM_LOCK     },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        { KeyEvent.VK_PAUSE,       Event.PAUSE        },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        { KeyEvent.VK_INSERT,      Event.INSERT       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * This field controls whether or not the event is sent back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * down to the peer once the target has processed it -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * false means it's sent to the peer, true means it's not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * @see #isConsumed()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    private boolean consumed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    private static final long serialVersionUID = 5488922509400504703L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * Initialize JNI field and method IDs for fields that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
       accessed from C.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   613
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   614
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   615
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   617
     * Creates an instance of {@code Event} with the specified target
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * component, time stamp, event type, <i>x</i> and <i>y</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * coordinates, keyboard key, state of the modifier keys, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * @param     target     the target component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @param     when       the time stamp.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @param     id         the event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * @param     x          the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * @param     y          the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * @param     key        the key pressed in a keyboard event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @param     modifiers  the state of the modifier keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * @param     arg        the specified argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    public Event(Object target, long when, int id, int x, int y, int key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                 int modifiers, Object arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        this.target = target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        this.when = when;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        this.id = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        this.x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        this.y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        this.key = key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        this.modifiers = modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        this.arg = arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        this.data = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        this.clickCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
          case ACTION_EVENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
          case WINDOW_DESTROY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
          case WINDOW_ICONIFY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
          case WINDOW_DEICONIFY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
          case WINDOW_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
          case SCROLL_LINE_UP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
          case SCROLL_LINE_DOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
          case SCROLL_PAGE_UP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
          case SCROLL_PAGE_DOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
          case SCROLL_ABSOLUTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
          case SCROLL_BEGIN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
          case SCROLL_END:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
          case LIST_SELECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
          case LIST_DESELECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
            consumed = true; // these types are not passed back to peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   664
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   665
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   666
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   668
     * Creates an instance of {@code Event}, with the specified target
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * component, time stamp, event type, <i>x</i> and <i>y</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * coordinates, keyboard key, state of the modifier keys, and an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   671
     * argument set to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * @param     target     the target component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * @param     when       the time stamp.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * @param     id         the event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * @param     x          the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * @param     y          the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * @param     key        the key pressed in a keyboard event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * @param     modifiers  the state of the modifier keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    public Event(Object target, long when, int id, int x, int y, int key, int modifiers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        this(target, when, id, x, y, key, modifiers, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   685
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   686
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   687
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   689
     * Creates an instance of {@code Event} with the specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * target component, event type, and argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * @param     target     the target component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * @param     id         the event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * @param     arg        the specified argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    public Event(Object target, int id, Object arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        this(target, 0, id, 0, 0, 0, 0, arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   700
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   701
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   702
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * Translates this event so that its <i>x</i> and <i>y</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * coordinates are increased by <i>dx</i> and <i>dy</i>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * This method translates an event relative to the given component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * This involves, at a minimum, translating the coordinates into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * local coordinate system of the given component. It may also involve
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * translating a region in the case of an expose event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * @param     dx     the distance to translate the <i>x</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * @param     dy     the distance to translate the <i>y</i> coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    public void translate(int dx, int dy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        this.x += dx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        this.y += dy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   721
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   722
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   723
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * Checks if the Shift key is down.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   726
     * @return    {@code true} if the key is down;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   727
     *            {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * @see       java.awt.Event#modifiers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * @see       java.awt.Event#controlDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * @see       java.awt.Event#metaDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    public boolean shiftDown() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        return (modifiers & SHIFT_MASK) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   737
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   738
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   739
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * Checks if the Control key is down.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   742
     * @return    {@code true} if the key is down;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   743
     *            {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * @see       java.awt.Event#modifiers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * @see       java.awt.Event#shiftDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * @see       java.awt.Event#metaDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    public boolean controlDown() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        return (modifiers & CTRL_MASK) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   753
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   754
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   755
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * Checks if the Meta key is down.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   759
     * @return    {@code true} if the key is down;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   760
     *            {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * @see       java.awt.Event#modifiers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * @see       java.awt.Event#shiftDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * @see       java.awt.Event#controlDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    public boolean metaDown() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        return (modifiers & META_MASK) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   770
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   771
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   772
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    void consume() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
          case KEY_PRESS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
          case KEY_RELEASE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
          case KEY_ACTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
          case KEY_ACTION_RELEASE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
              consumed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
              // event type cannot be consumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   788
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   789
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   790
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    boolean isConsumed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        return consumed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    /*
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   797
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   798
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   799
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * Returns the integer key-code associated with the key in this event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * as described in java.awt.Event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    static int getOldEventKey(KeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        int keyCode = e.getKeyCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        for (int i = 0; i < actionKeyCodes.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            if (actionKeyCodes[i][0] == keyCode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                return actionKeyCodes[i][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        return (int)e.getKeyChar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    /*
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   815
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   816
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   817
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * Returns a new KeyEvent char which corresponds to the int key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * of this old event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    char getKeyEventChar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
       for (int i = 0; i < actionKeyCodes.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            if (actionKeyCodes[i][1] == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                return KeyEvent.CHAR_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
       return (char)key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   832
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   833
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   834
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   836
     * Returns a string representing the state of this {@code Event}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * This method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * implementations. The returned string may be empty but may not be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   840
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * @return    the parameter string of this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        String str = "id=" + id + ",x=" + x + ",y=" + y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        if (key != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            str += ",key=" + key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        if (shiftDown()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            str += ",shift";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        if (controlDown()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            str += ",control";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        if (metaDown()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            str += ",meta";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        if (target != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            str += ",target=" + target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        if (arg != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            str += ",arg=" + arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        return str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   868
     * <b>NOTE:</b> The {@code Event} class is obsolete and is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20172
diff changeset
   869
     * available only for backwards compatibility.  It has been replaced
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   870
     * by the {@code AWTEvent} class and its subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     * Returns a representation of this event's values as a string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * @return    a string that represents the event and the values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     *                 of its member fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * @see       java.awt.Event#paramString
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   876
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        return getClass().getName() + "[" + paramString() + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
}