jdk/src/share/classes/javax/swing/JMenuItem.java
author henryjen
Wed, 18 Jun 2014 09:13:46 -0700
changeset 25201 4adc75e0c4e5
parent 23010 6dadb192ad81
permissions -rw-r--r--
8046485: Add missing @since tag under javax.swing.* Reviewed-by: alexsch, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20458
diff changeset
     2
 * Copyright (c) 1997, 2013, 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: 1639
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: 1639
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: 1639
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.EventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import javax.swing.plaf.basic.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * An implementation of an item in a menu. A menu item is essentially a button
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * sitting in a list. When the user selects the "button", the action
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * associated with the menu item is performed. A <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * contained in a <code>JPopupMenu</code> performs exactly that function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Menu items can be configured, and to some degree controlled, by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <code><a href="Action.html">Action</a></code>s.  Using an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <code>Action</code> with a menu item has many benefits beyond directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * configuring a menu item.  Refer to <a href="Action.html#buttonActions">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * Swing Components Supporting <code>Action</code></a> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * details, and you can find more information in <a
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 20169
diff changeset
    57
 * href="http://docs.oracle.com/javase/tutorial/uiswing/misc/action.html">How
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * to Use Actions</a>, a section in <em>The Java Tutorial</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * For further documentation and for examples, see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <a
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 20169
diff changeset
    62
 href="http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html">How to Use Menus</a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * in <em>The Java Tutorial.</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20455
diff changeset
    75
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *   attribute: isContainer false
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * description: An item which can be selected in a menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * @author Georges Saab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * @author David Karlton
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * @see JPopupMenu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * @see JMenu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * @see JCheckBoxMenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @see JRadioButtonMenuItem
25201
4adc75e0c4e5 8046485: Add missing @since tag under javax.swing.*
henryjen
parents: 23010
diff changeset
    89
 * @since 1.2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
    91
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
public class JMenuItem extends AbstractButton implements Accessible,MenuElement  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private static final String uiClassID = "MenuItemUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /* diagnostic aids -- should be false for production builds. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private static final boolean TRACE =   false; // trace creates and disposes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private static final boolean VERBOSE = false; // show reuse hits/misses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private static final boolean DEBUG =   false;  // show bad params, misc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    private boolean isMouseDragged = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Creates a <code>JMenuItem</code> with no set text or icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public JMenuItem() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        this(null, (Icon)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Creates a <code>JMenuItem</code> with the specified icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @param icon the icon of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public JMenuItem(Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        this(null, icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Creates a <code>JMenuItem</code> with the specified text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param text the text of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public JMenuItem(String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        this(text, (Icon)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * Creates a menu item whose properties are taken from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * specified <code>Action</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @param a the action of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public JMenuItem(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        this();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        setAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Creates a <code>JMenuItem</code> with the specified text and icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param text the text of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param icon the icon of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public JMenuItem(String text, Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        setModel(new DefaultButtonModel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        init(text, icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        initFocusability();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Creates a <code>JMenuItem</code> with the specified text and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * keyboard mnemonic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @param text the text of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @param mnemonic the keyboard mnemonic for the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public JMenuItem(String text, int mnemonic) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        setModel(new DefaultButtonModel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        init(text, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        setMnemonic(mnemonic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        initFocusability();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public void setModel(ButtonModel newModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        super.setModel(newModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if(newModel instanceof DefaultButtonModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            ((DefaultButtonModel)newModel).setMenuItem(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Inititalizes the focusability of the the <code>JMenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * <code>JMenuItem</code>'s are focusable, but subclasses may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * want to be, this provides them the opportunity to override this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * and invoke something else, or nothing at all. Refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * {@link javax.swing.JMenu#initFocusability} for the motivation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    void initFocusability() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        setFocusable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Initializes the menu item with the specified text and icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @param text the text of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @param icon the icon of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    protected void init(String text, Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        if(text != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            setText(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        if(icon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            setIcon(icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        // Listen for Focus events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        addFocusListener(new MenuItemFocusListener());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        setUIProperty("borderPainted", Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        setFocusPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        setHorizontalTextPosition(JButton.TRAILING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        setHorizontalAlignment(JButton.LEADING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    private static class MenuItemFocusListener implements FocusListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        public void focusGained(FocusEvent event) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        public void focusLost(FocusEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            // When focus is lost, repaint if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            // the focus information is painted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            JMenuItem mi = (JMenuItem)event.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            if(mi.isFocusPainted()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                mi.repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * Sets the look and feel object that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 11268
diff changeset
   233
     * @param ui  the <code>JMenuItemUI</code> L&amp;F object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *    attribute: visualUpdate true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *  description: The UI object that implements the Component's LookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public void setUI(MenuItemUI ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * Resets the UI property with a value from the current look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        setUI((MenuItemUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 11268
diff changeset
   256
     * Returns the suffix used to construct the name of the L&amp;F class used to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * render this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @return the string "MenuItemUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * Identifies the menu item as "armed". If the mouse button is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * released while it is over this item, the menu's action event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * will fire. If the mouse button is released elsewhere, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * event will not fire and the menu item will be disarmed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @param b true to arm the menu item so it can be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *    description: Mouse release will fire an action event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *         hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public void setArmed(boolean b) {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   280
        ButtonModel model = getModel();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        boolean oldValue = model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if(model.isArmed() != b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            model.setArmed(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * Returns whether the menu item is "armed".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @return true if the menu item is armed, and it can be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @see #setArmed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public boolean isArmed() {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   295
        ButtonModel model = getModel();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        return model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Enables or disables the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @param b  true to enable the item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *    description: Does the component react to user interaction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *          bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *      preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        // Make sure we aren't armed!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        if (!b && !UIManager.getBoolean("MenuItem.disabledAreNavigable")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            setArmed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        super.setEnabled(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * Returns true since <code>Menu</code>s, by definition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * should always be on top of all other windows.  If the menu is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * in an internal frame false is returned due to the rollover effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * for windows laf where the menu is not always on top.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    // package private
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    boolean alwaysOnTop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        // Fix for bug #4482165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        if (SwingUtilities.getAncestorOfClass(JInternalFrame.class, this) !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /* The keystroke which acts as the menu item's accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    private KeyStroke accelerator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * Sets the key combination which invokes the menu item's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * action listeners without navigating the menu hierarchy. It is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * UI's responsibility to install the correct action.  Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * when the keyboard accelerator is typed, it will work whether or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * not the menu is currently displayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @param keyStroke the <code>KeyStroke</code> which will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *          serve as an accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *     description: The keystroke combination which will invoke the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *                  JMenuItem's actionlisteners without navigating the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *                  menu hierarchy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *       preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public void setAccelerator(KeyStroke keyStroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        KeyStroke oldAccelerator = accelerator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        this.accelerator = keyStroke;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        firePropertyChange("accelerator", oldAccelerator, accelerator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * Returns the <code>KeyStroke</code> which serves as an accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * for the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * @return a <code>KeyStroke</code> object identifying the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *          accelerator key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    public KeyStroke getAccelerator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        return this.accelerator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    protected void configurePropertiesFromAction(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        super.configurePropertiesFromAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        configureAcceleratorFromAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    void setIconFromAction(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        Icon icon = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        if (a != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            icon = (Icon)a.getValue(Action.SMALL_ICON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        setIcon(icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    void largeIconChanged(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    void smallIconChanged(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        setIconFromAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    void configureAcceleratorFromAction(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        KeyStroke ks = (a==null) ? null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        setAccelerator(ks);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    protected void actionPropertyChanged(Action action, String propertyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        if (propertyName == Action.ACCELERATOR_KEY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            configureAcceleratorFromAction(action);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            super.actionPropertyChanged(action, propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * Processes a mouse event forwarded from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * <code>MenuSelectionManager</code> and changes the menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * selection, if necessary, by using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * <code>MenuSelectionManager</code>'s API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * Note: you do not have to forward the event to sub-components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * This is done automatically by the <code>MenuSelectionManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * @param e   a <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * @param path  the <code>MenuElement</code> path array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * @param manager   the <code>MenuSelectionManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    public void processMouseEvent(MouseEvent e,MenuElement path[],MenuSelectionManager manager) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        processMenuDragMouseEvent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                 new MenuDragMouseEvent(e.getComponent(), e.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                                        e.getWhen(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                                        e.getModifiers(), e.getX(), e.getY(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                                        e.getXOnScreen(), e.getYOnScreen(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                                        e.getClickCount(), e.isPopupTrigger(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                                        path, manager));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * Processes a key event forwarded from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * <code>MenuSelectionManager</code> and changes the menu selection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * if necessary, by using <code>MenuSelectionManager</code>'s API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * Note: you do not have to forward the event to sub-components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * This is done automatically by the <code>MenuSelectionManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @param e  a <code>KeyEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @param path the <code>MenuElement</code> path array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @param manager   the <code>MenuSelectionManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    public void processKeyEvent(KeyEvent e,MenuElement path[],MenuSelectionManager manager) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            System.out.println("in JMenuItem.processKeyEvent/3 for " + getText() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                   "  " + KeyStroke.getKeyStrokeForEvent(e));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        MenuKeyEvent mke = new MenuKeyEvent(e.getComponent(), e.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                                             e.getWhen(), e.getModifiers(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                                             e.getKeyCode(), e.getKeyChar(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                                             path, manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        processMenuKeyEvent(mke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        if (mke.isConsumed())  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            e.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * Handles mouse drag in a menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * @param e  a <code>MenuDragMouseEvent</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    public void processMenuDragMouseEvent(MenuDragMouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        switch (e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        case MouseEvent.MOUSE_ENTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            isMouseDragged = false; fireMenuDragMouseEntered(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        case MouseEvent.MOUSE_EXITED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            isMouseDragged = false; fireMenuDragMouseExited(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        case MouseEvent.MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            isMouseDragged = true; fireMenuDragMouseDragged(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        case MouseEvent.MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            if(isMouseDragged) fireMenuDragMouseReleased(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * Handles a keystroke in a menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @param e  a <code>MenuKeyEvent</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    public void processMenuKeyEvent(MenuKeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            System.out.println("in JMenuItem.processMenuKeyEvent for " + getText()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                                   "  " + KeyStroke.getKeyStrokeForEvent(e));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        switch (e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            fireMenuKeyPressed(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            fireMenuKeyReleased(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        case KeyEvent.KEY_TYPED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            fireMenuKeyTyped(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @param event a <code>MenuMouseDragEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    protected void fireMenuDragMouseEntered(MenuDragMouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            if (listeners[i]==MenuDragMouseListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                ((MenuDragMouseListener)listeners[i+1]).menuDragMouseEntered(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * @param event a <code>MenuDragMouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    protected void fireMenuDragMouseExited(MenuDragMouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            if (listeners[i]==MenuDragMouseListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                ((MenuDragMouseListener)listeners[i+1]).menuDragMouseExited(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @param event a <code>MenuDragMouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    protected void fireMenuDragMouseDragged(MenuDragMouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            if (listeners[i]==MenuDragMouseListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                ((MenuDragMouseListener)listeners[i+1]).menuDragMouseDragged(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @param event a <code>MenuDragMouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    protected void fireMenuDragMouseReleased(MenuDragMouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            if (listeners[i]==MenuDragMouseListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                ((MenuDragMouseListener)listeners[i+1]).menuDragMouseReleased(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * @param event a <code>MenuKeyEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    protected void fireMenuKeyPressed(MenuKeyEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            System.out.println("in JMenuItem.fireMenuKeyPressed for " + getText()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                                   "  " + KeyStroke.getKeyStrokeForEvent(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            if (listeners[i]==MenuKeyListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                ((MenuKeyListener)listeners[i+1]).menuKeyPressed(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * @param event a <code>MenuKeyEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    protected void fireMenuKeyReleased(MenuKeyEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            System.out.println("in JMenuItem.fireMenuKeyReleased for " + getText()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                                   "  " + KeyStroke.getKeyStrokeForEvent(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            if (listeners[i]==MenuKeyListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                ((MenuKeyListener)listeners[i+1]).menuKeyReleased(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * @param event a <code>MenuKeyEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    protected void fireMenuKeyTyped(MenuKeyEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            System.out.println("in JMenuItem.fireMenuKeyTyped for " + getText()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                                   "  " + KeyStroke.getKeyStrokeForEvent(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
            if (listeners[i]==MenuKeyListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                ((MenuKeyListener)listeners[i+1]).menuKeyTyped(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * Called by the <code>MenuSelectionManager</code> when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * <code>MenuElement</code> is selected or unselected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * @param isIncluded  true if this menu item is on the part of the menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     *                    path that changed, false if this menu is part of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     *                    a menu path that changed, but this particular part of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     *                    that path is still the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * @see MenuSelectionManager#setSelectedPath(MenuElement[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    public void menuSelectionChanged(boolean isIncluded) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        setArmed(isIncluded);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * This method returns an array containing the sub-menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * components for this menu component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * @return an array of <code>MenuElement</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    public MenuElement[] getSubElements() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        return new MenuElement[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * Returns the <code>java.awt.Component</code> used to paint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * this object. The returned component will be used to convert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * events and detect if an event is inside a menu component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * @return the <code>Component</code> that paints this menu item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    public Component getComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * Adds a <code>MenuDragMouseListener</code> to the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * @param l the <code>MenuDragMouseListener</code> to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    public void addMenuDragMouseListener(MenuDragMouseListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        listenerList.add(MenuDragMouseListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * Removes a <code>MenuDragMouseListener</code> from the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * @param l the <code>MenuDragMouseListener</code> to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    public void removeMenuDragMouseListener(MenuDragMouseListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        listenerList.remove(MenuDragMouseListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * Returns an array of all the <code>MenuDragMouseListener</code>s added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * to this JMenuItem with addMenuDragMouseListener().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * @return all of the <code>MenuDragMouseListener</code>s added or an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     *         array if no listeners have been added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    public MenuDragMouseListener[] getMenuDragMouseListeners() {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   726
        return listenerList.getListeners(MenuDragMouseListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * Adds a <code>MenuKeyListener</code> to the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * @param l the <code>MenuKeyListener</code> to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    public void addMenuKeyListener(MenuKeyListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        listenerList.add(MenuKeyListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * Removes a <code>MenuKeyListener</code> from the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * @param l the <code>MenuKeyListener</code> to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    public void removeMenuKeyListener(MenuKeyListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        listenerList.remove(MenuKeyListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * Returns an array of all the <code>MenuKeyListener</code>s added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * to this JMenuItem with addMenuKeyListener().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * @return all of the <code>MenuKeyListener</code>s added or an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     *         array if no listeners have been added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    public MenuKeyListener[] getMenuKeyListeners() {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   756
        return listenerList.getListeners(MenuKeyListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * See JComponent.readObject() for information about serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * Returns a string representation of this <code>JMenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * This method is intended to be used only for debugging purposes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * and the content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * @return  a string representation of this <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        return super.paramString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * Returns the <code>AccessibleContext</code> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * <code>JMenuItem</code>. For <code>JMenuItem</code>s,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * the <code>AccessibleContext</code> takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * <code>AccessibleJMenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * A new AccessibleJMenuItme instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @return an <code>AccessibleJMenuItem</code> that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     *         <code>AccessibleContext</code> of this <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            accessibleContext = new AccessibleJMenuItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * <code>JMenuItem</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * Java Accessibility API appropriate to menu item user-interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20455
diff changeset
   830
     * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
   834
    @SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    protected class AccessibleJMenuItem extends AccessibleAbstractButton implements ChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        private boolean isArmed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        private boolean hasFocus = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        private boolean isPressed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        private boolean isSelected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        AccessibleJMenuItem() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            JMenuItem.this.addChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            return AccessibleRole.MENU_ITEM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        private void fireAccessibilityFocusedEvent(JMenuItem toCheck) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            MenuElement [] path =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                MenuSelectionManager.defaultManager().getSelectedPath();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            if (path.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                Object menuItem = path[path.length - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                if (toCheck == menuItem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                        null, AccessibleState.FOCUSED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
         * Supports the change listener interface and fires property changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        public void stateChanged(ChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
                               Boolean.valueOf(false), Boolean.valueOf(true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            if (JMenuItem.this.getModel().isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                if (!isArmed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                    isArmed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                        null, AccessibleState.ARMED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                    // Fix for 4848220 moved here to avoid major memory leak
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                    // Here we will fire the event in case of JMenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                    // See bug 4910323 for details [zav]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                    fireAccessibilityFocusedEvent(JMenuItem.this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                if (isArmed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                    isArmed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                        AccessibleState.ARMED, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            if (JMenuItem.this.isFocusOwner()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                if (!hasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                    hasFocus = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                        null, AccessibleState.FOCUSED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                if (hasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                    hasFocus = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                        AccessibleState.FOCUSED, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            if (JMenuItem.this.getModel().isPressed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                if (!isPressed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                    isPressed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                        null, AccessibleState.PRESSED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                if (isPressed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                    isPressed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                        AccessibleState.PRESSED, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            if (JMenuItem.this.getModel().isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                if (!isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                    isSelected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                        null, AccessibleState.CHECKED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                    // Fix for 4848220 moved here to avoid major memory leak
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                    // Here we will fire the event in case of JMenu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                    // See bug 4910323 for details [zav]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                    fireAccessibilityFocusedEvent(JMenuItem.this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                if (isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                    isSelected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                    firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                        AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                        AccessibleState.CHECKED, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    } // inner class AccessibleJMenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
}