jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java
author alexsch
Wed, 24 Aug 2016 00:23:49 +0400
changeset 40719 4ae72a69bd3b
parent 35667 ed476aba94de
child 43722 25ba19c20260
permissions -rw-r--r--
8129854: Remove reflection from AWT/Swing classes Reviewed-by: serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
     2
 * Copyright (c) 1996, 2014, 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: 3938
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: 3938
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: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.EventObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.peer.ComponentPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.peer.LightweightPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.Field;
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
    33
import sun.awt.AWTAccessor;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
    34
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
8816
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
    36
import java.security.AccessControlContext;
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
    37
import java.security.AccessController;
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
    38
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * The root event class for all AWT events.
26749
b6598aa90114 8055326: Fix typos in client-related packages
serb
parents: 25859
diff changeset
    41
 * This class and its subclasses supersede the original
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * java.awt.Event class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Subclasses of this root AWTEvent class defined outside of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * java.awt.event package should define event ID values greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * the value defined by RESERVED_ID_MAX.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * The event masks defined in this class are needed by Component subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * which are using Component.enableEvents() to select for event types not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * selected by registered listeners. If a listener is registered on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * component, the appropriate event mask is already set internally by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * The masks are also used to specify to which types of events an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * AWTEventListener should listen. The masks are bitwise-ORed together
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * and passed to Toolkit.addAWTEventListener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @see Component#enableEvents
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @see Toolkit#addAWTEventListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @see java.awt.event.ActionEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @see java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @see java.awt.event.ComponentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @see java.awt.event.ContainerEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * @see java.awt.event.FocusEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @see java.awt.event.InputMethodEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @see java.awt.event.InvocationEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @see java.awt.event.ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * @see java.awt.event.HierarchyEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * @see java.awt.event.KeyEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * @see java.awt.event.MouseEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * @see java.awt.event.MouseWheelEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * @see java.awt.event.PaintEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * @see java.awt.event.TextEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * @see java.awt.event.WindowEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @author Carl Quinn
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * @author Amy Fowler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @since 1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
public abstract class AWTEvent extends EventObject {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
    81
    private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.AWTEvent");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private byte bdata[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * The event's id.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @see #getID()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @see #AWTEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    protected int id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Controls whether or not the event is sent back down to the peer once the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * source has processed it - false means it's sent to the peer; true means
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * it's not. Semantic events always have a 'true' value since they were
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * generated by the peer in response to a low-level event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @see #consume
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @see #isConsumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    protected boolean consumed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
8816
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   103
   /*
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   104
    * The event's AccessControlContext.
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   105
    */
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   106
    private transient volatile AccessControlContext acc =
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   107
        AccessController.getContext();
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   108
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   109
   /*
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   110
    * Returns the acc this event was constructed with.
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   111
    */
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   112
    final AccessControlContext getAccessControlContext() {
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   113
        if (acc == null) {
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   114
            throw new SecurityException("AWTEvent is missing AccessControlContext");
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   115
        }
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   116
        return acc;
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   117
    }
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   118
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    transient boolean focusManagerIsDispatching = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    transient boolean isPosted;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
6826
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   123
     * Indicates whether this AWTEvent was generated by the system as
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   124
     * opposed to by user code.
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   125
     */
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   126
    private transient boolean isSystemGenerated;
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   127
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   128
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * The event mask for selecting component events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   131
    public static final long COMPONENT_EVENT_MASK = 0x01;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * The event mask for selecting container events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   136
    public static final long CONTAINER_EVENT_MASK = 0x02;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * The event mask for selecting focus events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   141
    public static final long FOCUS_EVENT_MASK = 0x04;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * The event mask for selecting key events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   146
    public static final long KEY_EVENT_MASK = 0x08;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * The event mask for selecting mouse events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   151
    public static final long MOUSE_EVENT_MASK = 0x10;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * The event mask for selecting mouse motion events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   156
    public static final long MOUSE_MOTION_EVENT_MASK = 0x20;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * The event mask for selecting window events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   161
    public static final long WINDOW_EVENT_MASK = 0x40;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * The event mask for selecting action events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   166
    public static final long ACTION_EVENT_MASK = 0x80;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * The event mask for selecting adjustment events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   171
    public static final long ADJUSTMENT_EVENT_MASK = 0x100;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * The event mask for selecting item events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   176
    public static final long ITEM_EVENT_MASK = 0x200;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * The event mask for selecting text events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   181
    public static final long TEXT_EVENT_MASK = 0x400;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * The event mask for selecting input method events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   186
    public static final long INPUT_METHOD_EVENT_MASK = 0x800;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * The pseudo event mask for enabling input methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * We're using one bit in the eventMask so we don't need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * a separate field inputMethodsEnabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   193
    static final long INPUT_METHODS_ENABLED_MASK = 0x1000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * The event mask for selecting paint events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   198
    public static final long PAINT_EVENT_MASK = 0x2000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * The event mask for selecting invocation events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   203
    public static final long INVOCATION_EVENT_MASK = 0x4000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * The event mask for selecting hierarchy events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   208
    public static final long HIERARCHY_EVENT_MASK = 0x8000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * The event mask for selecting hierarchy bounds events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   213
    public static final long HIERARCHY_BOUNDS_EVENT_MASK = 0x10000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * The event mask for selecting mouse wheel events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   219
    public static final long MOUSE_WHEEL_EVENT_MASK = 0x20000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * The event mask for selecting window state events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   225
    public static final long WINDOW_STATE_EVENT_MASK = 0x40000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * The event mask for selecting window focus events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   231
    public static final long WINDOW_FOCUS_EVENT_MASK = 0x80000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * WARNING: there are more mask defined privately.  See
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * SunToolkit.GRAB_EVENT_MASK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * The maximum value for reserved AWT event IDs. Programs defining
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * their own event IDs should use IDs greater than this value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26749
diff changeset
   242
    public static final int RESERVED_ID_MAX = 1999;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    // security stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    private static Field inputEvent_CanAccessSystemClipboard_Field = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    private static final long serialVersionUID = -1825314779160409405L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   258
        AWTAccessor.setAWTEventAccessor(
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   259
            new AWTAccessor.AWTEventAccessor() {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   260
                public void setPosted(AWTEvent ev) {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   261
                    ev.isPosted = true;
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   262
                }
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   263
6826
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   264
                public void setSystemGenerated(AWTEvent ev) {
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   265
                    ev.isSystemGenerated = true;
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   266
                }
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   267
6826
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   268
                public boolean isSystemGenerated(AWTEvent ev) {
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   269
                    return ev.isSystemGenerated;
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   270
                }
8816
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   271
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   272
                public AccessControlContext getAccessControlContext(AWTEvent ev) {
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   273
                    return ev.getAccessControlContext();
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 7668
diff changeset
   274
                }
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   275
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   276
                public byte[] getBData(AWTEvent ev) {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   277
                    return ev.bdata;
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   278
                }
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   279
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   280
                public void setBData(AWTEvent ev, byte[] bdata) {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   281
                    ev.bdata = bdata;
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   282
                }
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 11270
diff changeset
   283
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   284
            });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Initialize JNI field and method IDs for fields that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * accessed from C.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * Constructs an AWTEvent object from the parameters of a 1.0-style event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @param event the old-style event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    public AWTEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        this(event.target, event.id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Constructs an AWTEvent object with the specified source object and type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @param source the object where the event originated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * @param id the event type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    public AWTEvent(Object source, int id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        super(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        this.id = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
          case ActionEvent.ACTION_PERFORMED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
          case ItemEvent.ITEM_STATE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
          case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
          case TextEvent.TEXT_VALUE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            consumed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * Retargets an event to a new source. This method is typically used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * retarget an event to a lightweight child Component of the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * heavyweight source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * This method is intended to be used only by event targeting subsystems,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * such as client-defined KeyboardFocusManagers. It is not for general
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * client use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @param newSource the new Object to which the event should be dispatched
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    public void setSource(Object newSource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        if (source == newSource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        Component comp = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        if (newSource instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            comp = (Component)newSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            while (comp != null && comp.peer != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                   (comp.peer instanceof LightweightPeer)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                comp = comp.parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            source = newSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            if (comp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                ComponentPeer peer = comp.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                    nativeSetSource(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    private native void nativeSetSource(ComponentPeer peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * Returns the event type.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   362
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   363
     * @return the event's type id
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public int getID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        return id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * Returns a String representation of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        String srcName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        if (source instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            srcName = ((Component)source).getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        } else if (source instanceof MenuComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            srcName = ((MenuComponent)source).getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return getClass().getName() + "[" + paramString() + "] on " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            (srcName != null? srcName : source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   384
     * Returns a string representing the state of this {@code Event}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * This method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * implementations. The returned string may be empty but may not be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   388
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @return  a string representation of this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    public String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Consumes this event, if this event can be consumed. Only low-level,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * system events can be consumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    protected void consume() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
          case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
          case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
          case MouseEvent.MOUSE_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
          case MouseEvent.MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
          case MouseEvent.MOUSE_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
          case MouseEvent.MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
          case MouseEvent.MOUSE_ENTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
          case MouseEvent.MOUSE_EXITED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
          case MouseEvent.MOUSE_WHEEL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
          case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
          case InputMethodEvent.CARET_POSITION_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
              consumed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
              // event type cannot be consumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * Returns whether this event has been consumed.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   422
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   423
     * @return {@code true} if this event has been consumed;
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 23010
diff changeset
   424
     *          otherwise {@code false}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    protected boolean isConsumed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        return consumed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * Converts a new event to an old one (used for compatibility).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * If the new event cannot be converted (because no old equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * exists) then this returns null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * Note: this method is here instead of in each individual new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * event class in java.awt.event because we don't want to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * it public and it needs to be called from java.awt.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    Event convertToOld() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        Object src = getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        int newid = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
          case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
          case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
              KeyEvent ke = (KeyEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
              if (ke.isActionKey()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                  newid = (id == KeyEvent.KEY_PRESSED?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                           Event.KEY_ACTION : Event.KEY_ACTION_RELEASE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
              int keyCode = ke.getKeyCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
              if (keyCode == KeyEvent.VK_SHIFT ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                  keyCode == KeyEvent.VK_CONTROL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                  keyCode == KeyEvent.VK_ALT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                  return null;  // suppress modifier keys in old event model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
              // no mask for button1 existed in old Event - strip it out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
              return new Event(src, ke.getWhen(), newid, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                               Event.getOldEventKey(ke),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                               (ke.getModifiers() & ~InputEvent.BUTTON1_MASK));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
          case MouseEvent.MOUSE_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
          case MouseEvent.MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
          case MouseEvent.MOUSE_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
          case MouseEvent.MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
          case MouseEvent.MOUSE_ENTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
          case MouseEvent.MOUSE_EXITED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
              MouseEvent me = (MouseEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
              // no mask for button1 existed in old Event - strip it out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
              Event olde = new Event(src, me.getWhen(), newid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                               me.getX(), me.getY(), 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                               (me.getModifiers() & ~InputEvent.BUTTON1_MASK));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
              olde.clickCount = me.getClickCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
              return olde;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
          case FocusEvent.FOCUS_GAINED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
              return new Event(src, Event.GOT_FOCUS, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
          case FocusEvent.FOCUS_LOST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
              return new Event(src, Event.LOST_FOCUS, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
          case WindowEvent.WINDOW_CLOSING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
          case WindowEvent.WINDOW_ICONIFIED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
          case WindowEvent.WINDOW_DEICONIFIED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
              return new Event(src, newid, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
          case ComponentEvent.COMPONENT_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
              if (src instanceof Frame || src instanceof Dialog) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                  Point p = ((Component)src).getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                  return new Event(src, 0, Event.WINDOW_MOVED, p.x, p.y, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
          case ActionEvent.ACTION_PERFORMED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
              ActionEvent ae = (ActionEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
              String cmd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
              if (src instanceof Button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                  cmd = ((Button)src).getLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
              } else if (src instanceof MenuItem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                  cmd = ((MenuItem)src).getLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
              } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                  cmd = ae.getActionCommand();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
              return new Event(src, 0, newid, 0, 0, 0, ae.getModifiers(), cmd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
          case ItemEvent.ITEM_STATE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
              ItemEvent ie = (ItemEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
              Object arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
              if (src instanceof List) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                  newid = (ie.getStateChange() == ItemEvent.SELECTED?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                           Event.LIST_SELECT : Event.LIST_DESELECT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                  arg = ie.getItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
              } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                  newid = Event.ACTION_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                  if (src instanceof Choice) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                      arg = ie.getItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                  } else { // Checkbox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                      arg = Boolean.valueOf(ie.getStateChange() == ItemEvent.SELECTED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
              return new Event(src, newid, arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
          case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
              AdjustmentEvent aje = (AdjustmentEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
              switch(aje.getAdjustmentType()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                case AdjustmentEvent.UNIT_INCREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                  newid = Event.SCROLL_LINE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                case AdjustmentEvent.UNIT_DECREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                  newid = Event.SCROLL_LINE_UP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                case AdjustmentEvent.BLOCK_INCREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                  newid = Event.SCROLL_PAGE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                case AdjustmentEvent.BLOCK_DECREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                  newid = Event.SCROLL_PAGE_UP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                case AdjustmentEvent.TRACK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                  if (aje.getValueIsAdjusting()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                      newid = Event.SCROLL_ABSOLUTE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                      newid = Event.SCROLL_END;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                  return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
              return new Event(src, newid, Integer.valueOf(aje.getValue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * Copies all private data from this event into that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * Space is allocated for the copied data that will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * freed when the that is finalized. Upon completion,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * this event is not changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    void copyPrivateDataInto(AWTEvent that) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        that.bdata = this.bdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        // Copy canAccessSystemClipboard value from this into that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        if (this instanceof InputEvent && that instanceof InputEvent) {
40719
4ae72a69bd3b 8129854: Remove reflection from AWT/Swing classes
alexsch
parents: 35667
diff changeset
   567
4ae72a69bd3b 8129854: Remove reflection from AWT/Swing classes
alexsch
parents: 35667
diff changeset
   568
            AWTAccessor.InputEventAccessor accessor
4ae72a69bd3b 8129854: Remove reflection from AWT/Swing classes
alexsch
parents: 35667
diff changeset
   569
                    = AWTAccessor.getInputEventAccessor();
4ae72a69bd3b 8129854: Remove reflection from AWT/Swing classes
alexsch
parents: 35667
diff changeset
   570
4ae72a69bd3b 8129854: Remove reflection from AWT/Swing classes
alexsch
parents: 35667
diff changeset
   571
            boolean b = accessor.canAccessSystemClipboard((InputEvent) this);
4ae72a69bd3b 8129854: Remove reflection from AWT/Swing classes
alexsch
parents: 35667
diff changeset
   572
            accessor.setCanAccessSystemClipboard((InputEvent) that, b);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        }
6826
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 5506
diff changeset
   574
        that.isSystemGenerated = this.isSystemGenerated;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    void dispatched() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        if (this instanceof InputEvent) {
40719
4ae72a69bd3b 8129854: Remove reflection from AWT/Swing classes
alexsch
parents: 35667
diff changeset
   579
            AWTAccessor.getInputEventAccessor().
4ae72a69bd3b 8129854: Remove reflection from AWT/Swing classes
alexsch
parents: 35667
diff changeset
   580
                    setCanAccessSystemClipboard((InputEvent) this, false);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
} // class AWTEvent