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