01 /*
02 * Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * 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.KeyEvent;
31 import java.awt.Component;
32
33 /**
34 * MenuKeyEvent is used to notify interested parties that
35 * the menu element has received a KeyEvent forwarded to it
36 * in a menu tree.
37 * <p>
38 * <strong>Warning:</strong>
39 * Serialized objects of this class will not be compatible with
40 * future Swing releases. The current serialization support is
41 * appropriate for short term storage or RMI between applications running
42 * the same version of Swing. As of 1.4, support for long term storage
43 * of all JavaBeans<sup><font size="-2">TM</font></sup>
44 * has been added to the <code>java.beans</code> package.
45 * Please see {@link java.beans.XMLEncoder}.
46 *
47 * @version 1.20 05/05/07
48 * @author Georges Saab
49 */
50 public class MenuKeyEvent extends KeyEvent {
51 private MenuElement path[];
52 private MenuSelectionManager manager;
53
54 /**
55 * Constructs a MenuKeyEvent object.
56 *
57 * @param source the Component that originated the event
58 * (typically <code>this</code>)
59 * @param id an int specifying the type of event, as defined
60 * in {@link java.awt.event.KeyEvent}
61 * @param when a long identifying the time the event occurred
62 * @param modifiers an int specifying any modifier keys held down,
63 * as specified in {@link java.awt.event.InputEvent}
64 * @param keyCode an int specifying the specific key that was pressed
65 * @param keyChar a char specifying the key's character value, if any
66 * -- null if the key has no character value
67 * @param p an array of MenuElement objects specifying a path
68 * to a menu item affected by the drag
69 * @param m a MenuSelectionManager object that handles selections
70 */
71 public MenuKeyEvent(Component source, int id, long when,
72 int modifiers, int keyCode, char keyChar, MenuElement p[],
73 MenuSelectionManager m) {
74 super (source, id, when, modifiers, keyCode, keyChar);
75 path = p;
76 manager = m;
77 }
78
79 /**
80 * Returns the path to the menu item referenced by this event.
81 *
82 * @return an array of MenuElement objects representing the path value
83 */
84 public MenuElement[] getPath() {
85 return path;
86 }
87
88 /**
89 * Returns the current menu selection manager.
90 *
91 * @return a MenuSelectionManager object
92 */
93 public MenuSelectionManager getMenuSelectionManager() {
94 return manager;
95 }
96 }
|