jdk/src/share/classes/javax/swing/event/MenuDragMouseEvent.java
author malenkov
Wed, 07 May 2008 23:20:32 +0400
changeset 466 6acd5ec503a8
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE Summary: Add the Transient annotation and support it (JSR-273) Reviewed-by: peterz, loneid
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
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
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public class MenuDragMouseEvent extends MouseEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private MenuElement path[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private MenuSelectionManager manager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Constructs a MenuDragMouseEvent object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * <p>Absolute coordinates xAbs and yAbs are set to source's location on screen plus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * 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
    58
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @param source        the Component that originated the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     *                      (typically <code>this</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @param id            an int specifying the type of event, as defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     *                      in {@link java.awt.event.MouseEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param when          a long identifying the time the event occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param modifiers     an int specifying any modifier keys held down,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *                      as specified in {@link java.awt.event.InputEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @param x             an int specifying the horizontal position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param y             an int specifying the vertical position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param clickCount    an int specifying the number of mouse-clicks
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param popupTrigger  a boolean -- true if the event {should?/did?}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *                      trigger a popup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @param p             an array of MenuElement objects specifying a path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *                        to a menu item affected by the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param m             a MenuSelectionManager object that handles selections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public MenuDragMouseEvent(Component source, int id, long when,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                              int modifiers, int x, int y, int clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                              boolean popupTrigger, MenuElement p[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                              MenuSelectionManager m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        super(source, id, when, modifiers, x, y, clickCount, popupTrigger);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        path = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        manager = m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Constructs a MenuDragMouseEvent object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * <p>Even if inconsistent values for relative and absolute coordinates are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * passed to the constructor, the MenuDragMouseEvent instance is still
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param source        the Component that originated the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *                      (typically <code>this</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @param id            an int specifying the type of event, as defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *                      in {@link java.awt.event.MouseEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @param when          a long identifying the time the event occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param modifiers     an int specifying any modifier keys held down,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *                      as specified in {@link java.awt.event.InputEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param x             an int specifying the horizontal position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param y             an int specifying the vertical position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @param xAbs          an int specifying the horizontal absolute position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @param yAbs          an int specifying the vertical absolute position at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *                      the event occurred, in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @param clickCount    an int specifying the number of mouse-clicks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @param popupTrigger  a boolean -- true if the event {should?/did?}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *                      trigger a popup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param p             an array of MenuElement objects specifying a path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *                        to a menu item affected by the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param m             a MenuSelectionManager object that handles selections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public MenuDragMouseEvent(Component source, int id, long when,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                              int modifiers, int x, int y, int xAbs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                              int yAbs, int clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                              boolean popupTrigger, MenuElement p[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                              MenuSelectionManager m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
              popupTrigger, MouseEvent.NOBUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        path = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        manager = m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Returns the path to the selected menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @return an array of MenuElement objects representing the path value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public MenuElement[] getPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return path;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Returns the current menu selection manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @return a MenuSelectionManager object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public MenuSelectionManager getMenuSelectionManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        return manager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
}