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