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