jdk/src/share/classes/java/awt/AWTEvent.java
author mchung
Tue, 29 Sep 2009 16:03:03 -0700
changeset 3938 ef327bd847c0
parent 3084 67ca55732362
child 5506 202f599c92aa
permissions -rw-r--r--
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes Summary: Replace calls to Logger with sun.util.logging.PlatformLogger Reviewed-by: prr, art, alexp, dcherepanov, igor, dav, anthony
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1996-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * The event mask for selecting component events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public final static long COMPONENT_EVENT_MASK = 0x01;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * The event mask for selecting container events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public final static long CONTAINER_EVENT_MASK = 0x02;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * The event mask for selecting focus events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public final static long FOCUS_EVENT_MASK = 0x04;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * The event mask for selecting key events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public final static long KEY_EVENT_MASK = 0x08;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * The event mask for selecting mouse events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public final static long MOUSE_EVENT_MASK = 0x10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * The event mask for selecting mouse motion events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public final static long MOUSE_MOTION_EVENT_MASK = 0x20;
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 window events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public final static long WINDOW_EVENT_MASK = 0x40;
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 action events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public final static long ACTION_EVENT_MASK = 0x80;
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 adjustment events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public final static long ADJUSTMENT_EVENT_MASK = 0x100;
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 item events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public final static long ITEM_EVENT_MASK = 0x200;
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 text events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public final static long TEXT_EVENT_MASK = 0x400;
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 input method events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public final static long INPUT_METHOD_EVENT_MASK = 0x800;
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 pseudo event mask for enabling input methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * We're using one bit in the eventMask so we don't need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * a separate field inputMethodsEnabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    final static long INPUT_METHODS_ENABLED_MASK = 0x1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * The event mask for selecting paint events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public final static long PAINT_EVENT_MASK = 0x2000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * The event mask for selecting invocation events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public final static long INVOCATION_EVENT_MASK = 0x4000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * The event mask for selecting hierarchy events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public final static long HIERARCHY_EVENT_MASK = 0x8000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * The event mask for selecting hierarchy bounds events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    public final static long HIERARCHY_BOUNDS_EVENT_MASK = 0x10000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * The event mask for selecting mouse wheel events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public final static long MOUSE_WHEEL_EVENT_MASK = 0x20000;
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 window state 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 WINDOW_STATE_EVENT_MASK = 0x40000;
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 focus 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_FOCUS_EVENT_MASK = 0x80000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * WARNING: there are more mask defined privately.  See
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * SunToolkit.GRAB_EVENT_MASK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * The maximum value for reserved AWT event IDs. Programs defining
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * their own event IDs should use IDs greater than this value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public final static int RESERVED_ID_MAX = 1999;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    // security stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    private static Field inputEvent_CanAccessSystemClipboard_Field = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    private static final long serialVersionUID = -1825314779160409405L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   233
        AWTAccessor.setAWTEventAccessor(
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   234
            new AWTAccessor.AWTEventAccessor() {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   235
                public void setPosted(AWTEvent ev) {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   236
                    ev.isPosted = true;
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   237
                }
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   238
            });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        if (inputEvent_CanAccessSystemClipboard_Field == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            inputEvent_CanAccessSystemClipboard_Field =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                (Field)java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                    new java.security.PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                            public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                                Field field = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                                    field = InputEvent.class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                        getDeclaredField("canAccessSystemClipboard");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                                    field.setAccessible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                                    return field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                                } catch (SecurityException e) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   254
                                    if (log.isLoggable(PlatformLogger.FINE)) {
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   255
                                        log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got SecurityException ", e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                                } catch (NoSuchFieldException e) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   258
                                    if (log.isLoggable(PlatformLogger.FINE)) {
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   259
                                        log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got NoSuchFieldException ", e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return inputEvent_CanAccessSystemClipboard_Field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * Initialize JNI field and method IDs for fields that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * accessed from C.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Constructs an AWTEvent object from the parameters of a 1.0-style event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @param event the old-style event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public AWTEvent(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        this(event.target, event.id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * Constructs an AWTEvent object with the specified source object and type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @param source the object where the event originated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @param id the event type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public AWTEvent(Object source, int id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        super(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        this.id = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
          case ActionEvent.ACTION_PERFORMED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
          case ItemEvent.ITEM_STATE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
          case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
          case TextEvent.TEXT_VALUE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            consumed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * Retargets an event to a new source. This method is typically used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * retarget an event to a lightweight child Component of the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * heavyweight source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * This method is intended to be used only by event targeting subsystems,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * such as client-defined KeyboardFocusManagers. It is not for general
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * client use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @param newSource the new Object to which the event should be dispatched
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    public void setSource(Object newSource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        if (source == newSource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        Component comp = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        if (newSource instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            comp = (Component)newSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            while (comp != null && comp.peer != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                   (comp.peer instanceof LightweightPeer)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                comp = comp.parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            source = newSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            if (comp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                ComponentPeer peer = comp.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                    nativeSetSource(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    private native void nativeSetSource(ComponentPeer peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * Returns the event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    public int getID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        return id;
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
     * Returns a String representation of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        String srcName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        if (source instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            srcName = ((Component)source).getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        } else if (source instanceof MenuComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            srcName = ((MenuComponent)source).getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        return getClass().getName() + "[" + paramString() + "] on " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            (srcName != null? srcName : source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * Returns a string representing the state of this <code>Event</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * This method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * implementations. The returned string may be empty but may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @return  a string representation of this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    public String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * Consumes this event, if this event can be consumed. Only low-level,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * system events can be consumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    protected void consume() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
          case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
          case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
          case MouseEvent.MOUSE_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
          case MouseEvent.MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
          case MouseEvent.MOUSE_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
          case MouseEvent.MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
          case MouseEvent.MOUSE_ENTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
          case MouseEvent.MOUSE_EXITED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
          case MouseEvent.MOUSE_WHEEL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
          case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
          case InputMethodEvent.CARET_POSITION_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
              consumed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
              // event type cannot be consumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * Returns whether this event has been consumed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    protected boolean isConsumed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        return consumed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * Converts a new event to an old one (used for compatibility).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * If the new event cannot be converted (because no old equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * exists) then this returns null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * Note: this method is here instead of in each individual new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * event class in java.awt.event because we don't want to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * it public and it needs to be called from java.awt.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    Event convertToOld() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        Object src = getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        int newid = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
          case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
          case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
              KeyEvent ke = (KeyEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
              if (ke.isActionKey()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                  newid = (id == KeyEvent.KEY_PRESSED?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                           Event.KEY_ACTION : Event.KEY_ACTION_RELEASE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
              int keyCode = ke.getKeyCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
              if (keyCode == KeyEvent.VK_SHIFT ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                  keyCode == KeyEvent.VK_CONTROL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                  keyCode == KeyEvent.VK_ALT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                  return null;  // suppress modifier keys in old event model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
              // no mask for button1 existed in old Event - strip it out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
              return new Event(src, ke.getWhen(), newid, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                               Event.getOldEventKey(ke),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                               (ke.getModifiers() & ~InputEvent.BUTTON1_MASK));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
          case MouseEvent.MOUSE_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
          case MouseEvent.MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
          case MouseEvent.MOUSE_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
          case MouseEvent.MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
          case MouseEvent.MOUSE_ENTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
          case MouseEvent.MOUSE_EXITED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
              MouseEvent me = (MouseEvent)this;
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
              Event olde = new Event(src, me.getWhen(), newid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                               me.getX(), me.getY(), 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                               (me.getModifiers() & ~InputEvent.BUTTON1_MASK));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
              olde.clickCount = me.getClickCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
              return olde;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
          case FocusEvent.FOCUS_GAINED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
              return new Event(src, Event.GOT_FOCUS, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
          case FocusEvent.FOCUS_LOST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
              return new Event(src, Event.LOST_FOCUS, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
          case WindowEvent.WINDOW_CLOSING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
          case WindowEvent.WINDOW_ICONIFIED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
          case WindowEvent.WINDOW_DEICONIFIED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
              return new Event(src, newid, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
          case ComponentEvent.COMPONENT_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
              if (src instanceof Frame || src instanceof Dialog) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                  Point p = ((Component)src).getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                  return new Event(src, 0, Event.WINDOW_MOVED, p.x, p.y, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
          case ActionEvent.ACTION_PERFORMED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
              ActionEvent ae = (ActionEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
              String cmd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
              if (src instanceof Button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                  cmd = ((Button)src).getLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
              } else if (src instanceof MenuItem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                  cmd = ((MenuItem)src).getLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
              } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                  cmd = ae.getActionCommand();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
              return new Event(src, 0, newid, 0, 0, 0, ae.getModifiers(), cmd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
          case ItemEvent.ITEM_STATE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
              ItemEvent ie = (ItemEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
              Object arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
              if (src instanceof List) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                  newid = (ie.getStateChange() == ItemEvent.SELECTED?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                           Event.LIST_SELECT : Event.LIST_DESELECT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                  arg = ie.getItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
              } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                  newid = Event.ACTION_EVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                  if (src instanceof Choice) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                      arg = ie.getItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                  } else { // Checkbox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                      arg = Boolean.valueOf(ie.getStateChange() == ItemEvent.SELECTED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
              return new Event(src, newid, arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
          case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
              AdjustmentEvent aje = (AdjustmentEvent)this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
              switch(aje.getAdjustmentType()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                case AdjustmentEvent.UNIT_INCREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                  newid = Event.SCROLL_LINE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                case AdjustmentEvent.UNIT_DECREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                  newid = Event.SCROLL_LINE_UP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                case AdjustmentEvent.BLOCK_INCREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                  newid = Event.SCROLL_PAGE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                case AdjustmentEvent.BLOCK_DECREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                  newid = Event.SCROLL_PAGE_UP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                case AdjustmentEvent.TRACK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                  if (aje.getValueIsAdjusting()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                      newid = Event.SCROLL_ABSOLUTE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                      newid = Event.SCROLL_END;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                  return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
              return new Event(src, newid, Integer.valueOf(aje.getValue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * Copies all private data from this event into that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * Space is allocated for the copied data that will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * freed when the that is finalized. Upon completion,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * this event is not changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    void copyPrivateDataInto(AWTEvent that) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        that.bdata = this.bdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        // Copy canAccessSystemClipboard value from this into that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        if (this instanceof InputEvent && that instanceof InputEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            Field field = get_InputEvent_CanAccessSystemClipboard();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            if (field != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                    boolean b = field.getBoolean(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                    field.setBoolean(that, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                } catch(IllegalAccessException e) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   551
                    if (log.isLoggable(PlatformLogger.FINE)) {
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   552
                        log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                }
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    void dispatched() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        if (this instanceof InputEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            Field field = get_InputEvent_CanAccessSystemClipboard();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            if (field != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                    field.setBoolean(this, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                } catch(IllegalAccessException e) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   566
                    if (log.isLoggable(PlatformLogger.FINE)) {
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   567
                        log.fine("AWTEvent.dispatched() got IllegalAccessException ", e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
} // class AWTEvent