jdk/src/share/classes/javax/swing/event/MenuDragMouseEvent.java
author malenkov
Wed, 30 Apr 2014 19:28:05 +0400
changeset 24544 c0133e7c7162
parent 23010 6dadb192ad81
permissions -rw-r--r--
8041917: unexcepted behavior of LineBorder while using Boolean variable true Reviewed-by: alexsch, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20458
diff changeset
     2
 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.swing.MenuElement;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.MenuSelectionManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.EventObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.event.MouseEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * MenuDragMouseEvent is used to notify interested parties that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * the menu element has received a MouseEvent forwarded to it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * under drag conditions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 11268
diff changeset
    44
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @author Georges Saab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
    50
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public class MenuDragMouseEvent extends MouseEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private MenuElement path[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private MenuSelectionManager manager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Constructs a MenuDragMouseEvent object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * <p>Absolute coordinates xAbs and yAbs are set to source's location on screen plus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * relative coordinates x and y. xAbs and yAbs are set to zero if the source is not showing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param source        the Component that originated the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *                      (typically <code>this</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @param id            an int specifying the type of event, as defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *                      in {@link java.awt.event.MouseEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param when          a long identifying the time the event occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param modifiers     an int specifying any modifier keys held down,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *                      as specified in {@link java.awt.event.InputEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @param x             an int specifying the horizontal position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param y             an int specifying the vertical position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param clickCount    an int specifying the number of mouse-clicks
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param popupTrigger  a boolean -- true if the event {should?/did?}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *                      trigger a popup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param p             an array of MenuElement objects specifying a path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *                        to a menu item affected by the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param m             a MenuSelectionManager object that handles selections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public MenuDragMouseEvent(Component source, int id, long when,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                              int modifiers, int x, int y, int clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                              boolean popupTrigger, MenuElement p[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                              MenuSelectionManager m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        super(source, id, when, modifiers, x, y, clickCount, popupTrigger);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        path = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        manager = m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Constructs a MenuDragMouseEvent object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * <p>Even if inconsistent values for relative and absolute coordinates are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * passed to the constructor, the MenuDragMouseEvent instance is still
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param source        the Component that originated the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *                      (typically <code>this</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param id            an int specifying the type of event, as defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *                      in {@link java.awt.event.MouseEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param when          a long identifying the time the event occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param modifiers     an int specifying any modifier keys held down,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *                      as specified in {@link java.awt.event.InputEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param x             an int specifying the horizontal position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @param y             an int specifying the vertical position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @param xAbs          an int specifying the horizontal absolute position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param yAbs          an int specifying the vertical absolute position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @param clickCount    an int specifying the number of mouse-clicks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param popupTrigger  a boolean -- true if the event {should?/did?}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *                      trigger a popup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param p             an array of MenuElement objects specifying a path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *                        to a menu item affected by the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param m             a MenuSelectionManager object that handles selections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public MenuDragMouseEvent(Component source, int id, long when,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                              int modifiers, int x, int y, int xAbs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                              int yAbs, int clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                              boolean popupTrigger, MenuElement p[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                              MenuSelectionManager m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
              popupTrigger, MouseEvent.NOBUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        path = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        manager = m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Returns the path to the selected menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @return an array of MenuElement objects representing the path value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public MenuElement[] getPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        return path;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Returns the current menu selection manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @return a MenuSelectionManager object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public MenuSelectionManager getMenuSelectionManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        return manager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
}