2
|
1 |
/*
|
|
2 |
* Copyright 1998-2006 Sun Microsystems, Inc. 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. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
package javax.swing.event;
|
|
26 |
|
|
27 |
import javax.swing.MenuElement;
|
|
28 |
import javax.swing.MenuSelectionManager;
|
|
29 |
import java.util.EventObject;
|
|
30 |
import java.awt.event.MouseEvent;
|
|
31 |
import 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<sup><font size="-2">TM</font></sup>
|
|
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 |
public class MenuDragMouseEvent extends MouseEvent {
|
|
51 |
private MenuElement path[];
|
|
52 |
private MenuSelectionManager manager;
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Constructs a MenuDragMouseEvent object.
|
|
56 |
* <p>Absolute coordinates xAbs and yAbs are set to source's location on screen plus
|
|
57 |
* relative coordinates x and y. xAbs and yAbs are set to zero if the source is not showing.
|
|
58 |
*
|
|
59 |
* @param source the Component that originated the event
|
|
60 |
* (typically <code>this</code>)
|
|
61 |
* @param id an int specifying the type of event, as defined
|
|
62 |
* in {@link java.awt.event.MouseEvent}
|
|
63 |
* @param when a long identifying the time the event occurred
|
|
64 |
* @param modifiers an int specifying any modifier keys held down,
|
|
65 |
* as specified in {@link java.awt.event.InputEvent}
|
|
66 |
* @param x an int specifying the horizontal position at which
|
|
67 |
* the event occurred, in pixels
|
|
68 |
* @param y an int specifying the vertical position at which
|
|
69 |
* the event occurred, in pixels
|
|
70 |
* @param clickCount an int specifying the number of mouse-clicks
|
|
71 |
* @param popupTrigger a boolean -- true if the event {should?/did?}
|
|
72 |
* trigger a popup
|
|
73 |
* @param p an array of MenuElement objects specifying a path
|
|
74 |
* to a menu item affected by the drag
|
|
75 |
* @param m a MenuSelectionManager object that handles selections
|
|
76 |
* @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
|
|
77 |
*/
|
|
78 |
public MenuDragMouseEvent(Component source, int id, long when,
|
|
79 |
int modifiers, int x, int y, int clickCount,
|
|
80 |
boolean popupTrigger, MenuElement p[],
|
|
81 |
MenuSelectionManager m) {
|
|
82 |
super(source, id, when, modifiers, x, y, clickCount, popupTrigger);
|
|
83 |
path = p;
|
|
84 |
manager = m;
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Constructs a MenuDragMouseEvent object.
|
|
89 |
* <p>Even if inconsistent values for relative and absolute coordinates are
|
|
90 |
* passed to the constructor, the MenuDragMouseEvent instance is still
|
|
91 |
* created.
|
|
92 |
* @param source the Component that originated the event
|
|
93 |
* (typically <code>this</code>)
|
|
94 |
* @param id an int specifying the type of event, as defined
|
|
95 |
* in {@link java.awt.event.MouseEvent}
|
|
96 |
* @param when a long identifying the time the event occurred
|
|
97 |
* @param modifiers an int specifying any modifier keys held down,
|
|
98 |
* as specified in {@link java.awt.event.InputEvent}
|
|
99 |
* @param x an int specifying the horizontal position at which
|
|
100 |
* the event occurred, in pixels
|
|
101 |
* @param y an int specifying the vertical position at which
|
|
102 |
* the event occurred, in pixels
|
|
103 |
* @param xAbs an int specifying the horizontal absolute position at which
|
|
104 |
* the event occurred, in pixels
|
|
105 |
* @param yAbs an int specifying the vertical absolute position at which
|
|
106 |
* the event occurred, in pixels
|
|
107 |
* @param clickCount an int specifying the number of mouse-clicks
|
|
108 |
* @param popupTrigger a boolean -- true if the event {should?/did?}
|
|
109 |
* trigger a popup
|
|
110 |
* @param p an array of MenuElement objects specifying a path
|
|
111 |
* to a menu item affected by the drag
|
|
112 |
* @param m a MenuSelectionManager object that handles selections
|
|
113 |
* @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
|
|
114 |
* @since 1.6
|
|
115 |
*/
|
|
116 |
public MenuDragMouseEvent(Component source, int id, long when,
|
|
117 |
int modifiers, int x, int y, int xAbs,
|
|
118 |
int yAbs, int clickCount,
|
|
119 |
boolean popupTrigger, MenuElement p[],
|
|
120 |
MenuSelectionManager m) {
|
|
121 |
super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
|
|
122 |
popupTrigger, MouseEvent.NOBUTTON);
|
|
123 |
path = p;
|
|
124 |
manager = m;
|
|
125 |
}
|
|
126 |
|
|
127 |
/**
|
|
128 |
* Returns the path to the selected menu item.
|
|
129 |
*
|
|
130 |
* @return an array of MenuElement objects representing the path value
|
|
131 |
*/
|
|
132 |
public MenuElement[] getPath() {
|
|
133 |
return path;
|
|
134 |
}
|
|
135 |
|
|
136 |
/**
|
|
137 |
* Returns the current menu selection manager.
|
|
138 |
*
|
|
139 |
* @return a MenuSelectionManager object
|
|
140 |
*/
|
|
141 |
public MenuSelectionManager getMenuSelectionManager() {
|
|
142 |
return manager;
|
|
143 |
}
|
|
144 |
}
|