jdk/src/share/classes/java/awt/event/MouseEvent.java
author dav
Fri, 22 May 2009 16:09:45 +0400
changeset 2810 fa49c6a06baf
parent 1962 6c293d33645b
child 5506 202f599c92aa
permissions -rw-r--r--
6799099: All automatic regression tests that create Robot fail on X11 Reviewed-by: art, ant
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 440
diff changeset
     2
 * Copyright 1996-2008 Sun Microsystems, Inc.  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
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.event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.IllegalComponentStateException;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
    35
import java.awt.MouseInfo;
2810
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
    36
import sun.awt.SunToolkit;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * An event which indicates that a mouse action occurred in a component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * A mouse action is considered to occur in a particular component if and only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * if the mouse cursor is over the unobscured part of the component's bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * when the action happens.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * For lightweight components, such as Swing's components, mouse events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * are only dispatched to the component if the mouse event type has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * enabled on the component. A mouse event type is enabled by adding the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * appropriate mouse-based {@code EventListener} to the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * ({@link MouseListener} or {@link MouseMotionListener}), or by invoking
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * {@link Component#enableEvents(long)} with the appropriate mask parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * ({@code AWTEvent.MOUSE_EVENT_MASK} or {@code AWTEvent.MOUSE_MOTION_EVENT_MASK}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * If the mouse event type has not been enabled on the component, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * corresponding mouse events are dispatched to the first ancestor that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * has enabled the mouse event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * For example, if a {@code MouseListener} has been added to a component, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * {@code enableEvents(AWTEvent.MOUSE_EVENT_MASK)} has been invoked, then all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * the events defined by {@code MouseListener} are dispatched to the component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * On the other hand, if a {@code MouseMotionListener} has not been added and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * {@code enableEvents} has not been invoked with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * {@code AWTEvent.MOUSE_MOTION_EVENT_MASK}, then mouse motion events are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * dispatched to the component. Instead the mouse motion events are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * dispatched to the first ancestors that has enabled mouse motion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * This low-level event is generated by a component object for:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <li>Mouse Events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *     <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *     <li>a mouse button is pressed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *     <li>a mouse button is released
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *     <li>a mouse button is clicked (pressed and released)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *     <li>the mouse cursor enters the unobscured part of component's geometry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *     <li>the mouse cursor exits the unobscured part of component's geometry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *     </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <li> Mouse Motion Events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *     <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *     <li>the mouse is moved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *     <li>the mouse is dragged
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *     </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * A <code>MouseEvent</code> object is passed to every
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <code>MouseListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * or <code>MouseAdapter</code> object which is registered to receive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * the "interesting" mouse events using the component's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <code>addMouseListener</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * (<code>MouseAdapter</code> objects implement the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <code>MouseListener</code> interface.) Each such listener object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * gets a <code>MouseEvent</code> containing the mouse event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * A <code>MouseEvent</code> object is also passed to every
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * <code>MouseMotionListener</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * <code>MouseMotionAdapter</code> object which is registered to receive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * mouse motion events using the component's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * <code>addMouseMotionListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * method. (<code>MouseMotionAdapter</code> objects implement the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * <code>MouseMotionListener</code> interface.) Each such listener object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * gets a <code>MouseEvent</code> containing the mouse motion event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * When a mouse button is clicked, events are generated and sent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * registered <code>MouseListener</code>s.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * The state of modal keys can be retrieved using {@link InputEvent#getModifiers}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * and {@link InputEvent#getModifiersEx}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * The button mask returned by {@link InputEvent#getModifiers} reflects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * only the button that changed state, not the current state of all buttons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * (Note: Due to overlap in the values of ALT_MASK/BUTTON2_MASK and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * META_MASK/BUTTON3_MASK, this is not always true for mouse events involving
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * modifier keys).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * To get the state of all buttons and modifier keys, use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * {@link InputEvent#getModifiersEx}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * The button which has changed state is returned by {@link MouseEvent#getButton}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * For example, if the first mouse button is pressed, events are sent in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * following order:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *    <b   >id           </b   >   <b   >modifiers   </b   > <b   >button </b   >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 *    <code>MOUSE_PRESSED</code>:  <code>BUTTON1_MASK</code> <code>BUTTON1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 *    <code>MOUSE_RELEASED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 *    <code>MOUSE_CLICKED</code>:  <code>BUTTON1_MASK</code> <code>BUTTON1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * When multiple mouse buttons are pressed, each press, release, and click
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * results in a separate event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * For example, if the user presses <b>button 1</b> followed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * <b>button 2</b>, and then releases them in the same order,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * the following sequence of events is generated:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *    <b   >id           </b   >   <b   >modifiers   </b   > <b   >button </b   >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *    <code>MOUSE_PRESSED</code>:  <code>BUTTON1_MASK</code> <code>BUTTON1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 *    <code>MOUSE_PRESSED</code>:  <code>BUTTON2_MASK</code> <code>BUTTON2</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *    <code>MOUSE_RELEASED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *    <code>MOUSE_CLICKED</code>:  <code>BUTTON1_MASK</code> <code>BUTTON1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 *    <code>MOUSE_RELEASED</code>: <code>BUTTON2_MASK</code> <code>BUTTON2</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *    <code>MOUSE_CLICKED</code>:  <code>BUTTON2_MASK</code> <code>BUTTON2</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * If <b>button 2</b> is released first, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * <code>MOUSE_RELEASED</code>/<code>MOUSE_CLICKED</code> pair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * for <code>BUTTON2_MASK</code> arrives first,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * followed by the pair for <code>BUTTON1_MASK</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * <p>
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   140
 * Some extra mouse buttons are added to extend the standard set of buttons
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   141
 * represented by the following constants:{@code BUTTON1}, {@code BUTTON2}, and {@code BUTTON3}.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   142
 * Extra buttons have no assigned {@code BUTTONx}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   143
 * constants as well as their button masks have no assigned {@code BUTTONx_DOWN_MASK}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   144
 * constants. Nevertheless, ordinal numbers starting from 4 may be
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   145
 * used as button numbers (button ids). Values obtained by the
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   146
 * {@link InputEvent#getMaskForButton(int) getMaskForButton(button)} method may be used
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   147
 * as button masks.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   148
 * <p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 * <code>MOUSE_DRAGGED</code> events are delivered to the <code>Component</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 * in which the mouse button was pressed until the mouse button is released
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * (regardless of whether the mouse position is within the bounds of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * <code>Component</code>).  Due to platform-dependent Drag&Drop implementations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * <code>MOUSE_DRAGGED</code> events may not be delivered during a native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * Drag&Drop operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * In a multi-screen environment mouse drag events are delivered to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * <code>Component</code> even if the mouse position is outside the bounds of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * <code>GraphicsConfiguration</code> associated with that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * <code>Component</code>. However, the reported position for mouse drag events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * in this case may differ from the actual mouse position:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * <li>In a multi-screen environment without a virtual device:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 * The reported coordinates for mouse drag events are clipped to fit within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 * bounds of the <code>GraphicsConfiguration</code> associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 * the <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 * <li>In a multi-screen environment with a virtual device:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 * <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 * The reported coordinates for mouse drag events are clipped to fit within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 * bounds of the virtual device associated with the <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 * </ul>
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   172
 * <p>
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   173
 * An unspecified behavior will be caused if the {@code id} parameter
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   174
 * of any particular {@code MouseEvent} instance is not
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   175
 * in the range from {@code MOUSE_FIRST} to {@code MOUSE_LAST}-1
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   176
 * ({@code MOUSE_WHEEL} is not acceptable).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 * @author Carl Quinn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * @see MouseAdapter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 * @see MouseListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 * @see MouseMotionAdapter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 * @see MouseMotionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 * @see MouseWheelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mouselistener.html">Tutorial: Writing a Mouse Listener</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mousemotionlistener.html">Tutorial: Writing a Mouse Motion Listener</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * @since 1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
public class MouseEvent extends InputEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * The first number in the range of ids used for mouse events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public static final int MOUSE_FIRST         = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * The last number in the range of ids used for mouse events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public static final int MOUSE_LAST          = 507;
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 "mouse clicked" event. This <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * occurs when a mouse button is pressed and released.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public static final int MOUSE_CLICKED = MOUSE_FIRST;
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 "mouse pressed" event. This <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * occurs when a mouse button is pushed down.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public static final int MOUSE_PRESSED = 1 + MOUSE_FIRST; //Event.MOUSE_DOWN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * The "mouse released" event. This <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * occurs when a mouse button is let up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    public static final int MOUSE_RELEASED = 2 + MOUSE_FIRST; //Event.MOUSE_UP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * The "mouse moved" event. This <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * occurs when the mouse position changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public static final int MOUSE_MOVED = 3 + MOUSE_FIRST; //Event.MOUSE_MOVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * The "mouse entered" event. This <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * occurs when the mouse cursor enters the unobscured part of component's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * geometry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public static final int MOUSE_ENTERED = 4 + MOUSE_FIRST; //Event.MOUSE_ENTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * The "mouse exited" event. This <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * occurs when the mouse cursor exits the unobscured part of component's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * geometry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public static final int MOUSE_EXITED = 5 + MOUSE_FIRST; //Event.MOUSE_EXIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * The "mouse dragged" event. This <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * occurs when the mouse position changes while a mouse button is pressed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    public static final int MOUSE_DRAGGED = 6 + MOUSE_FIRST; //Event.MOUSE_DRAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * The "mouse wheel" event.  This is the only <code>MouseWheelEvent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * It occurs when a mouse equipped with a wheel has its wheel rotated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public static final int MOUSE_WHEEL = 7 + MOUSE_FIRST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * Indicates no mouse buttons; used by {@link #getButton}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public static final int NOBUTTON = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Indicates mouse button #1; used by {@link #getButton}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public static final int BUTTON1 = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Indicates mouse button #2; used by {@link #getButton}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    public static final int BUTTON2 = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * Indicates mouse button #3; used by {@link #getButton}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public static final int BUTTON3 = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * The mouse event's x coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * The x value is relative to the component that fired the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @see #getX()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    int x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * The mouse event's y coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * The y value is relative to the component that fired the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @see #getY()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    int y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * The mouse event's x absolute coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * In a virtual device multi-screen environment in which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * desktop area could span multiple physical screen devices,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * this coordinate is relative to the virtual coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Otherwise, this coordinate is relative to the coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * associated with the Component's GraphicsConfiguration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    private int xAbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * The mouse event's y absolute coordinate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * In a virtual device multi-screen environment in which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * desktop area could span multiple physical screen devices,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * this coordinate is relative to the virtual coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * Otherwise, this coordinate is relative to the coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * associated with the Component's GraphicsConfiguration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    private int yAbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * Indicates the number of quick consecutive clicks of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * a mouse button.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * clickCount will be valid for only three mouse events :<BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * <code>MOUSE_CLICKED</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * <code>MOUSE_PRESSED</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * <code>MOUSE_RELEASED</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * For the above, the <code>clickCount</code> will be at least 1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * For all other events the count will be 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @see #getClickCount().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    int clickCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * Indicates which, if any, of the mouse buttons has changed state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     *
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   337
     * The valid values are ranged from 0 to the value returned by the
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   338
     * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()} method.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   339
     * This range already includes constants {@code NOBUTTON}, {@code BUTTON1},
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   340
     * {@code BUTTON2}, and {@code BUTTON3}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   341
     * if these buttons are present. So it is allowed to use these constants too.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   342
     * For example, for a mouse with two buttons this field may contain the following values:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   343
     * <ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   344
     * <li> 0 ({@code NOBUTTON})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   345
     * <li> 1 ({@code BUTTON1})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   346
     * <li> 2 ({@code BUTTON2})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   347
     * </ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   348
     * If a mouse has 5 buttons, this field may contain the following values:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   349
     * <ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   350
     * <li> 0 ({@code NOBUTTON})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   351
     * <li> 1 ({@code BUTTON1})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   352
     * <li> 2 ({@code BUTTON2})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   353
     * <li> 3 ({@code BUTTON3})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   354
     * <li> 4
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   355
     * <li> 5
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   356
     * </ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   357
     * If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled()} disabled by Java
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   358
     * then the field may not contain the value larger than {@code BUTTON3}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @serial
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   360
     * @see #getButton()
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   361
     * @see java.awt.Toolkit#areExtraMouseButtonsEnabled()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    int button;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * A property used to indicate whether a Popup Menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * should appear  with a certain gestures.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * If <code>popupTrigger</code> = <code>false</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * no popup menu should appear.  If it is <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * then a popup menu should appear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @see java.awt.PopupMenu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @see #isPopupTrigger()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    boolean popupTrigger = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    private static final long serialVersionUID = -991214153494842848L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
2810
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   383
    /**
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   384
     * A number of buttons available on the mouse at the {@code Toolkit} machinery startup.
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   385
     */
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   386
    private static int cachedNumberOfButtons;
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   387
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        NativeLibLoader.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        }
2810
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   394
        final Toolkit tk = Toolkit.getDefaultToolkit();
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   395
        if (tk instanceof SunToolkit) {
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   396
            cachedNumberOfButtons = ((SunToolkit)tk).getNumberOfButtons();
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   397
        } else {
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   398
            //It's expected that some toolkits (Headless,
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   399
            //whatever besides SunToolkit) could also operate.
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   400
            cachedNumberOfButtons = 3;
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 1962
diff changeset
   401
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * Initialize JNI field and method IDs for fields that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
       accessed from C.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * Returns the absolute x, y position of the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * In a virtual device multi-screen environment in which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * desktop area could span multiple physical screen devices,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * these coordinates are relative to the virtual coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * Otherwise, these coordinates are relative to the coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * associated with the Component's GraphicsConfiguration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * @return a <code>Point</code> object containing the absolute  x
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *  and y coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @see java.awt.GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public Point getLocationOnScreen(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
      return new Point(xAbs, yAbs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * Returns the absolute horizontal x position of the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * In a virtual device multi-screen environment in which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * desktop area could span multiple physical screen devices,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * this coordinate is relative to the virtual coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * Otherwise, this coordinate is relative to the coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * associated with the Component's GraphicsConfiguration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * @return x  an integer indicating absolute horizontal position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @see java.awt.GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    public int getXOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        return xAbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * Returns the absolute vertical y position of the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * In a virtual device multi-screen environment in which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * desktop area could span multiple physical screen devices,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * this coordinate is relative to the virtual coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * Otherwise, this coordinate is relative to the coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * associated with the Component's GraphicsConfiguration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @return y  an integer indicating absolute vertical position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @see java.awt.GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public int getYOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        return yAbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * Constructs a <code>MouseEvent</code> object with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * specified source component,
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   465
     * type, time, modifiers, coordinates, click count, popupTrigger flag,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   466
     * and button number.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * <p>
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   468
     * Creating an invalid event (such
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * as by using more than one of the old _MASKs, or modifier/button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * values which don't match) results in unspecified behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * An invocation of the form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger, button)</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * behaves in exactly the same way as the invocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * <tt> {@link #MouseEvent(Component, int, long, int, int, int,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * int, int, int, boolean, int) MouseEvent}(source, id, when, modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * x, y, xAbs, yAbs, clickCount, popupTrigger, button)</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * where xAbs and yAbs defines as source's location on screen plus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * relative coordinates x and y.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * xAbs and yAbs are set to zero if the source is not showing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * This method throws an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * <code>IllegalArgumentException</code> if <code>source</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     *
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   484
     * @param source       The <code>Component</code> that originated the event
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   485
     * @param id              An integer indicating the type of event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   486
     *                     For information on allowable values, see
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   487
     *                     the class description for {@link MouseEvent}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   488
     * @param when         A long integer that gives the time the event occurred.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   489
     *                     Passing negative or zero value
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   490
     *                     is not recommended
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   491
     * @param modifiers    The modifier keys down during event (e.g. shift, ctrl,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *                     alt, meta)
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   493
     *                     Passing negative parameter
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   494
     *                     is not recommended.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   495
     *                     Zero value means that no modifiers were passed.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   496
     *                     Use either an extended _DOWN_MASK or old _MASK modifiers,
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   497
     *                     however do not mix models in the one event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   498
     *                     The extended modifiers are preferred for using
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   499
     * @param x            The horizontal x coordinate for the mouse location.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   500
     *                       It is allowed to pass negative values
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   501
     * @param y            The vertical y coordinate for the mouse location.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   502
     *                       It is allowed to pass negative values
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   503
     * @param clickCount   The number of mouse clicks associated with event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   504
     *                       Passing negative value
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   505
     *                       is not recommended
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   506
     * @param popupTrigger A boolean that equals {@code true} if this event
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   507
     *                     is a trigger for a popup menu
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   508
     * @param button       An integer that indicates, which of the mouse buttons has
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   509
     *                     changed its state.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   510
     * The following rules are applied to this parameter:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   511
     * <ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   512
     * <li>If support for the extended mouse buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   513
     * {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   514
     * then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   515
     * {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   516
     * {@code BUTTON3}.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   517
     * <li> If support for the extended mouse buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   518
     * {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   519
     * then it is allowed to create {@code MouseEvent} objects with
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   520
     * the standard buttons.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   521
     * In case the support for extended mouse buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   522
     * {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   523
     * in addition to the standard buttons, {@code MouseEvent} objects can be created
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   524
     * using buttons from the range starting from 4 to
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   525
     * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   526
     * if the mouse has more than three buttons.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   527
     * </ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   528
     * @throws IllegalArgumentException if {@code button} is less then zero
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   529
     * @throws IllegalArgumentException if <code>source</code> is null
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   530
     * @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   531
     *                                  {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   532
     * @throws IllegalArgumentException if {@code button} is greater then the
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   533
     *                                  {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   534
     *                                  for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   535
     *                                  by Java
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * @throws IllegalArgumentException if an invalid <code>button</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *            value is passed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * @throws IllegalArgumentException if <code>source</code> is null
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   539
     * @see #getSource()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   540
     * @see #getID()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   541
     * @see #getWhen()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   542
     * @see #getModifiers()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   543
     * @see #getX()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   544
     * @see #getY()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   545
     * @see #getClickCount()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   546
     * @see #isPopupTrigger()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   547
     * @see #getButton()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    public MouseEvent(Component source, int id, long when, int modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                      int x, int y, int clickCount, boolean popupTrigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                      int button)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        this(source, id, when, modifiers, x, y, 0, 0, clickCount, popupTrigger, button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        Point eventLocationOnScreen = new Point(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
          eventLocationOnScreen = source.getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
          this.xAbs = eventLocationOnScreen.x + x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
          this.yAbs = eventLocationOnScreen.y + y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        } catch (IllegalComponentStateException e){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
          this.xAbs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
          this.yAbs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * Constructs a <code>MouseEvent</code> object with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * specified source component,
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   569
     * type, modifiers, coordinates, click count, and popupTrigger flag.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * An invocation of the form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger)</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * behaves in exactly the same way as the invocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * <tt> {@link #MouseEvent(Component, int, long, int, int, int,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * int, int, int, boolean, int) MouseEvent}(source, id, when, modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * x, y, xAbs, yAbs, clickCount, popupTrigger, MouseEvent.NOBUTTON)</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * where xAbs and yAbs defines as source's location on screen plus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * relative coordinates x and y.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * xAbs and yAbs are set to zero if the source is not showing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * This method throws an <code>IllegalArgumentException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * if <code>source</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     *
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   582
     * @param source       The <code>Component</code> that originated the event
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   583
     * @param id              An integer indicating the type of event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   584
     *                     For information on allowable values, see
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   585
     *                     the class description for {@link MouseEvent}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   586
     * @param when         A long integer that gives the time the event occurred.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   587
     *                     Passing negative or zero value
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   588
     *                     is not recommended
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   589
     * @param modifiers    The modifier keys down during event (e.g. shift, ctrl,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     *                     alt, meta)
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   591
     *                     Passing negative parameter
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   592
     *                     is not recommended.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   593
     *                     Zero value means that no modifiers were passed.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   594
     *                     Use either an extended _DOWN_MASK or old _MASK modifiers,
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   595
     *                     however do not mix models in the one event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   596
     *                     The extended modifiers are preferred for using
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   597
     * @param x            The horizontal x coordinate for the mouse location.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   598
     *                       It is allowed to pass negative values
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   599
     * @param y            The vertical y coordinate for the mouse location.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   600
     *                       It is allowed to pass negative values
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   601
     * @param clickCount   The number of mouse clicks associated with event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   602
     *                       Passing negative value
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   603
     *                       is not recommended
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   604
     * @param popupTrigger A boolean that equals {@code true} if this event
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   605
     *                     is a trigger for a popup menu
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * @throws IllegalArgumentException if <code>source</code> is null
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   607
     * @see #getSource()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   608
     * @see #getID()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   609
     * @see #getWhen()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   610
     * @see #getModifiers()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   611
     * @see #getX()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   612
     * @see #getY()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   613
     * @see #getClickCount()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   614
     * @see #isPopupTrigger()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     public MouseEvent(Component source, int id, long when, int modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                      int x, int y, int clickCount, boolean popupTrigger) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        this(source, id, when, modifiers, x, y, clickCount, popupTrigger, NOBUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   622
    /* if the button is an extra button and it is released or clicked then in Xsystem its state
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   623
       is not modified. Exclude this button number from ExtModifiers mask.*/
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   624
    transient private boolean shouldExcludeButtonFromExtModifiers = false;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   625
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   626
    /**
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   627
     * {@inheritDoc}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   628
     */
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   629
    public int getModifiersEx() {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   630
        int tmpModifiers = modifiers;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   631
        if (shouldExcludeButtonFromExtModifiers) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   632
            tmpModifiers &= ~(InputEvent.getMaskForButton(getButton()));
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   633
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   634
        return tmpModifiers & ~JDK_1_3_MODIFIERS;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   635
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   636
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * Constructs a <code>MouseEvent</code> object with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * specified source component,
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   640
     * type, time, modifiers, coordinates, absolute coordinates, click count, popupTrigger flag,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   641
     * and button number.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * <p>
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   643
     * Creating an invalid event (such
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * as by using more than one of the old _MASKs, or modifier/button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * values which don't match) results in unspecified behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * Even if inconsistent values for relative and absolute coordinates are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * passed to the constructor, the mouse event instance is still
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * created and no exception is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * This method throws an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * <code>IllegalArgumentException</code> if <code>source</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     *
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   653
     * @param source       The <code>Component</code> that originated the event
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   654
     * @param id              An integer indicating the type of event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   655
     *                     For information on allowable values, see
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   656
     *                     the class description for {@link MouseEvent}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   657
     * @param when         A long integer that gives the time the event occurred.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   658
     *                     Passing negative or zero value
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   659
     *                     is not recommended
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   660
     * @param modifiers    The modifier keys down during event (e.g. shift, ctrl,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     *                     alt, meta)
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   662
     *                     Passing negative parameter
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   663
     *                     is not recommended.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   664
     *                     Zero value means that no modifiers were passed.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   665
     *                     Use either an extended _DOWN_MASK or old _MASK modifiers,
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   666
     *                     however do not mix models in the one event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   667
     *                     The extended modifiers are preferred for using
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   668
     * @param x            The horizontal x coordinate for the mouse location.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   669
     *                       It is allowed to pass negative values
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   670
     * @param y            The vertical y coordinate for the mouse location.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   671
     *                       It is allowed to pass negative values
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   672
     * @param xAbs           The absolute horizontal x coordinate for the mouse location
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   673
     *                       It is allowed to pass negative values
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   674
     * @param yAbs           The absolute vertical y coordinate for the mouse location
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   675
     *                       It is allowed to pass negative values
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   676
     * @param clickCount   The number of mouse clicks associated with event.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   677
     *                       Passing negative value
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   678
     *                       is not recommended
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   679
     * @param popupTrigger A boolean that equals {@code true} if this event
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   680
     *                     is a trigger for a popup menu
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   681
     * @param button       An integer that indicates, which of the mouse buttons has
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   682
     *                     changed its state.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   683
     * The following rules are applied to this parameter:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   684
     * <ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   685
     * <li>If support for the extended mouse buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   686
     * {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   687
     * then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   688
     * {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   689
     * {@code BUTTON3}.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   690
     * <li> If support for the extended mouse buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   691
     * {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   692
     * then it is allowed to create {@code MouseEvent} objects with
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   693
     * the standard buttons.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   694
     * In case the support for extended mouse buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   695
     * {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   696
     * in addition to the standard buttons, {@code MouseEvent} objects can be created
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   697
     * using buttons from the range starting from 4 to
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   698
     * {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   699
     * if the mouse has more than three buttons.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   700
     * </ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   701
     * @throws IllegalArgumentException if {@code button} is less then zero
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   702
     * @throws IllegalArgumentException if <code>source</code> is null
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   703
     * @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   704
     *                                  {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   705
     * @throws IllegalArgumentException if {@code button} is greater then the
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   706
     *                                  {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   707
     *                                  for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   708
     *                                  by Java
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * @throws IllegalArgumentException if an invalid <code>button</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     *            value is passed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * @throws IllegalArgumentException if <code>source</code> is null
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   712
     * @see #getSource()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   713
     * @see #getID()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   714
     * @see #getWhen()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   715
     * @see #getModifiers()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   716
     * @see #getX()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   717
     * @see #getY()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   718
     * @see #getXOnScreen()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   719
     * @see #getYOnScreen()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   720
     * @see #getClickCount()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   721
     * @see #isPopupTrigger()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   722
     * @see #getButton()
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   723
     * @see #button
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   724
     * @see Toolkit#areExtraMouseButtonsEnabled()
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   725
     * @see java.awt.MouseInfo#getNumberOfButtons()
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   726
     * @see InputEvent#getMaskForButton(int)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    public MouseEvent(Component source, int id, long when, int modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                      int x, int y, int xAbs, int yAbs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                      int clickCount, boolean popupTrigger, int button)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        super(source, id, when, modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        this.x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        this.y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        this.xAbs = xAbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        this.yAbs = yAbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        this.clickCount = clickCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        this.popupTrigger = popupTrigger;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   740
        if (button < NOBUTTON){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   741
            throw new IllegalArgumentException("Invalid button value :" + button);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        }
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   743
        if (button > BUTTON3) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   744
            if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   745
                throw new IllegalArgumentException("Extra mouse events are disabled " + button);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   746
            } else {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   747
                if (button > cachedNumberOfButtons) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   748
                    throw new IllegalArgumentException("Nonexistent button " + button);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   749
                }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   750
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   751
            // XToolkit: extra buttons are not reporting about their state correctly.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   752
            // Being pressed they report the state=0 both on the press and on the release.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   753
            // For 1-3 buttons the state value equals zero on press and non-zero on release.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   754
            // Other modifiers like Shift, ALT etc seem report well with extra buttons.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   755
            // The problem reveals as follows: one button is pressed and then another button is pressed and released.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   756
            // So, the getModifiersEx() would not be zero due to a first button and we will skip this modifier.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   757
            // This may have to be moved into the peer code instead if possible.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   758
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   759
            if (getModifiersEx() != 0) { //There is at least one more button in a pressed state.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   760
                if (id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   761
                    System.out.println("MEvent. CASE!");
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   762
                    shouldExcludeButtonFromExtModifiers = true;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   763
                }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   764
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   765
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   766
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        this.button = button;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   768
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            setNewModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        } else if ((getModifiers() == 0) &&
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   772
                   (getModifiersEx() != 0 || button != NOBUTTON) &&
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   773
                   (button <= BUTTON3))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            setOldModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * Returns the horizontal x position of the event relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * source component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * @return x  an integer indicating horizontal position relative to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     *            the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    public int getX() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        return x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * Returns the vertical y position of the event relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * source component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * @return y  an integer indicating vertical position relative to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     *            the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    public int getY() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        return y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * Returns the x,y position of the event relative to the source component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @return a <code>Point</code> object containing the x and y coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     *         relative to the source component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    public Point getPoint() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        int x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        int y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            x = this.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            y = this.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        return new Point(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * Translates the event's coordinates to a new position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * by adding specified <code>x</code> (horizontal) and <code>y</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * (vertical) offsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * @param x the horizontal x value to add to the current x
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     *          coordinate position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * @param y the vertical y value to add to the current y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                coordinate position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    public synchronized void translatePoint(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        this.x += x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        this.y += y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * Returns the number of mouse clicks associated with this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * @return integer value for the number of clicks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    public int getClickCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        return clickCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * Returns which, if any, of the mouse buttons has changed state.
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   844
     * The returned value is ranged
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   845
     * from 0 to the {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   846
     * value.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   847
     * The returned value includes at least the following constants:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   848
     * <ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   849
     * <li> {@code NOBUTTON}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   850
     * <li> {@code BUTTON1}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   851
     * <li> {@code BUTTON2}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   852
     * <li> {@code BUTTON3}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   853
     * </ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   854
     * It is allowed to use those constants to compare with the returned button number in the application.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   855
     * For example,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   856
     * <pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   857
     * if (anEvent.getButton() == MouseEvent.BUTTON1) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   858
     * </pre>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   859
     * In particular, for a mouse with one, two, or three buttons this method may return the following values:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   860
     * <ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   861
     * <li> 0 ({@code NOBUTTON})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   862
     * <li> 1 ({@code BUTTON1})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   863
     * <li> 2 ({@code BUTTON2})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   864
     * <li> 3 ({@code BUTTON3})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   865
     * </ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   866
     * Button numbers greater then {@code BUTTON3} have no constant identifier. So if a mouse with five buttons is
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   867
     * installed, this method may return the following values:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   868
     * <ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   869
     * <li> 0 ({@code NOBUTTON})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   870
     * <li> 1 ({@code BUTTON1})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   871
     * <li> 2 ({@code BUTTON2})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   872
     * <li> 3 ({@code BUTTON3})
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   873
     * <li> 4
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   874
     * <li> 5
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   875
     * </ul>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   876
     * <p>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   877
     * Note: If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   878
     * then the AWT event subsystem does not produce mouse events for the extended mouse
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   879
     * buttons. So it is not expected that this method returns anything except {@code NOBUTTON}, {@code BUTTON1},
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   880
     * {@code BUTTON2}, {@code BUTTON3}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     *
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   882
     * @return one of the values from 0 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   883
     *         if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   884
     *         That range includes {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, {@code BUTTON3};
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   885
     *         <br>
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   886
     *         {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2} or {@code BUTTON3}
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   887
     *         if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * @since 1.4
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   889
     * @see Toolkit#areExtraMouseButtonsEnabled()
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   890
     * @see java.awt.MouseInfo#getNumberOfButtons()
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   891
     * @see #MouseEvent(Component, int, long, int, int, int, int, int, int, boolean, int)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   892
     * @see InputEvent#getMaskForButton(int)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    public int getButton() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        return button;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * Returns whether or not this mouse event is the popup menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     * trigger event for the platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     * <p><b>Note</b>: Popup menus are triggered differently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     * on different systems. Therefore, <code>isPopupTrigger</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * should be checked in both <code>mousePressed</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     * and <code>mouseReleased</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * for proper cross-platform functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * @return boolean, true if this event is the popup menu trigger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     *         for this platform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    public boolean isPopupTrigger() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        return popupTrigger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    /**
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   915
     * Returns a <code>String</code> instance describing the modifier keys and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * mouse buttons that were down during the event, such as "Shift",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * or "Ctrl+Shift". These strings can be localized by changing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * the <code>awt.properties</code> file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * <p>
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   920
     * Note that the <code>InputEvent.ALT_MASK</code> and
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   921
     * <code>InputEvent.BUTTON2_MASK</code> have equal values,
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   922
     * so the "Alt" string is returned for both modifiers.  Likewise,
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   923
     * the <code>InputEvent.META_MASK</code> and
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   924
     * <code>InputEvent.BUTTON3_MASK</code> have equal values,
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   925
     * so the "Meta" string is returned for both modifiers.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   926
     * <p>
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   927
     * Note that passing negative parameter is incorrect,
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   928
     * and will cause the returning an unspecified string.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   929
     * Zero parameter means that no modifiers were passed and will
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   930
     * cause the returning an empty string.
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   931
     * <p>
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   932
     * @param modifiers A modifier mask describing the modifier keys and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     *                  mouse buttons that were down during the event
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   934
     * @return string   string text description of the combination of modifier
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     *                  keys and mouse buttons that were down during the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * @see InputEvent#getModifiersExText(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    public static String getMouseModifiersText(int modifiers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        StringBuilder buf = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        if ((modifiers & InputEvent.ALT_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            buf.append(Toolkit.getProperty("AWT.alt", "Alt"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            buf.append("+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        if ((modifiers & InputEvent.META_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
            buf.append(Toolkit.getProperty("AWT.meta", "Meta"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
            buf.append("+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
        if ((modifiers & InputEvent.CTRL_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            buf.append(Toolkit.getProperty("AWT.control", "Ctrl"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            buf.append("+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
            buf.append(Toolkit.getProperty("AWT.shift", "Shift"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            buf.append("+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            buf.append("+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
            buf.append(Toolkit.getProperty("AWT.button1", "Button1"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            buf.append("+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        if ((modifiers & InputEvent.BUTTON2_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
            buf.append(Toolkit.getProperty("AWT.button2", "Button2"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
            buf.append("+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        if ((modifiers & InputEvent.BUTTON3_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            buf.append(Toolkit.getProperty("AWT.button3", "Button3"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            buf.append("+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        }
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   973
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   974
        int mask;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   975
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   976
        // TODO: add a toolkit field that holds a number of button on the mouse.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   977
        // As the method getMouseModifiersText() is static and obtain
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   978
        // an integer as a parameter then we may not restrict this with the number
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   979
        // of buttons installed on the mouse.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   980
        // It's a temporary solution. We need to somehow hold the number of buttons somewhere else.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   981
        for (int i = 1; i <= cachedNumberOfButtons; i++){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   982
            mask = InputEvent.getMaskForButton(i);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   983
            if ((modifiers & mask) != 0 &&
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   984
                buf.indexOf(Toolkit.getProperty("AWT.button"+i, "Button"+i)) == -1) //1,2,3 buttons may already be there; so don't duplicate it.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   985
            {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   986
                buf.append(Toolkit.getProperty("AWT.button"+i, "Button"+i));
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   987
                buf.append("+");
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   988
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   989
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
   990
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
        if (buf.length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
            buf.setLength(buf.length()-1); // remove trailing '+'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        return buf.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * Returns a parameter string identifying this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * This method is useful for event-logging and for debugging.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * @return a string identifying the event and its attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
    public String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        StringBuilder str = new StringBuilder(80);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
          case MOUSE_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
              str.append("MOUSE_PRESSED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
          case MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
              str.append("MOUSE_RELEASED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
          case MOUSE_CLICKED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
              str.append("MOUSE_CLICKED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
          case MOUSE_ENTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
              str.append("MOUSE_ENTERED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
          case MOUSE_EXITED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
              str.append("MOUSE_EXITED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
          case MOUSE_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
              str.append("MOUSE_MOVED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
          case MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
              str.append("MOUSE_DRAGGED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
          case MOUSE_WHEEL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
              str.append("MOUSE_WHEEL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
           default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
              str.append("unknown type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        // (x,y) coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        str.append(",(").append(x).append(",").append(y).append(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        str.append(",absolute(").append(xAbs).append(",").append(yAbs).append(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
  1039
        if (id != MOUSE_DRAGGED && id != MOUSE_MOVED){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
  1040
            str.append(",button=").append(getButton());
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
  1041
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
        if (getModifiers() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
            str.append(",modifiers=").append(getMouseModifiersText(modifiers));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        if (getModifiersEx() != 0) {
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
  1048
            //Using plain "modifiers" here does show an excluded extended buttons in the string event representation.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
  1049
            //getModifiersEx() solves the problem.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 715
diff changeset
  1050
            str.append(",extModifiers=").append(getModifiersExText(getModifiersEx()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        str.append(",clickCount=").append(clickCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
        return str.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * Sets new modifiers by the old ones.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * Also sets button.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    private void setNewModifiers() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        if ((modifiers & BUTTON1_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
            modifiers |= BUTTON1_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        if ((modifiers & BUTTON2_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
            modifiers |= BUTTON2_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        if ((modifiers & BUTTON3_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            modifiers |= BUTTON3_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
        if (id == MOUSE_PRESSED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
            || id == MOUSE_RELEASED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
            || id == MOUSE_CLICKED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            if ((modifiers & BUTTON1_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                button = BUTTON1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                modifiers &= ~BUTTON2_MASK & ~BUTTON3_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                if (id != MOUSE_PRESSED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                    modifiers &= ~BUTTON1_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
            } else if ((modifiers & BUTTON2_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                button = BUTTON2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                modifiers &= ~BUTTON1_MASK & ~BUTTON3_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
                if (id != MOUSE_PRESSED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
                    modifiers &= ~BUTTON2_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
            } else if ((modifiers & BUTTON3_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
                button = BUTTON3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                modifiers &= ~BUTTON1_MASK & ~BUTTON2_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                if (id != MOUSE_PRESSED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                    modifiers &= ~BUTTON3_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
        if ((modifiers & InputEvent.ALT_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
            modifiers |= InputEvent.ALT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        if ((modifiers & InputEvent.META_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
            modifiers |= InputEvent.META_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
            modifiers |= InputEvent.SHIFT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        if ((modifiers & InputEvent.CTRL_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
            modifiers |= InputEvent.CTRL_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     * Sets old modifiers by the new ones.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    private void setOldModifiers() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        if (id == MOUSE_PRESSED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            || id == MOUSE_RELEASED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
            || id == MOUSE_CLICKED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
            switch(button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
            case BUTTON1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                modifiers |= BUTTON1_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            case BUTTON2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
                modifiers |= BUTTON2_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
            case BUTTON3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
                modifiers |= BUTTON3_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
            if ((modifiers & BUTTON1_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                modifiers |= BUTTON1_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
            if ((modifiers & BUTTON2_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
                modifiers |= BUTTON2_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
            if ((modifiers & BUTTON3_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                modifiers |= BUTTON3_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        if ((modifiers & ALT_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
            modifiers |= ALT_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        if ((modifiers & META_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
            modifiers |= META_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        if ((modifiers & SHIFT_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
            modifiers |= SHIFT_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
        if ((modifiers & CTRL_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
            modifiers |= CTRL_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
        if ((modifiers & ALT_GRAPH_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
            modifiers |= ALT_GRAPH_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     * Sets new modifiers by the old ones.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
      throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
        if (getModifiers() != 0 && getModifiersEx() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            setNewModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
}