jdk/src/share/classes/javax/swing/event/MenuKeyEvent.java
author alexsch
Tue, 13 Dec 2011 18:38:39 +0400
changeset 11268 f0e59c4852de
parent 5506 202f599c92aa
child 20458 f2423fb3fd19
permissions -rw-r--r--
7116950: Reduce number of warnings in swing Reviewed-by: art
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2001, 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.KeyEvent;
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
 * MenuKeyEvent is used to notify interested parties that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * the menu element has received a KeyEvent forwarded to it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * in a menu tree.
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
 */
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 MenuKeyEvent extends KeyEvent {
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 MenuKeyEvent object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * @param source     the Component that originated the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *                     (typically <code>this</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param id         an int specifying the type of event, as defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *                     in {@link java.awt.event.KeyEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @param when       a long identifying the time the event occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param modifiers     an int specifying any modifier keys held down,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     *                      as specified in {@link java.awt.event.InputEvent}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param keyCode    an int specifying the specific key that was pressed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @param keyChar    a char specifying the key's character value, if any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *                   -- null if the key has no character value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param p          an array of MenuElement objects specifying a path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *                     to a menu item affected by the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param m          a MenuSelectionManager object that handles selections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public MenuKeyEvent(Component source, int id, long when, int modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                        int keyCode, char keyChar,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                        MenuElement p[], MenuSelectionManager m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        super(source, id, when, modifiers, keyCode, keyChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        path = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        manager = m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Returns the path to the menu item referenced by this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @return an array of MenuElement objects representing the path value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public MenuElement[] getPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return path;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Returns the current menu selection manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @return a MenuSelectionManager object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public MenuSelectionManager getMenuSelectionManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        return manager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
}