jdk/src/share/classes/javax/swing/JMenuItem.java
author malenkov
Wed, 07 May 2008 23:20:32 +0400
changeset 466 6acd5ec503a8
parent 2 90ce3da70b43
child 1301 15e81207e1f2
permissions -rw-r--r--
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE Summary: Add the Transient annotation and support it (JSR-273) Reviewed-by: peterz, loneid
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * href="http://java.sun.com/docs/books/tutorial/uiswing/misc/action.html">How
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 href="http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html">How to Use Menus</a>
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
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
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
public class JMenuItem extends AbstractButton implements Accessible,MenuElement  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private static final String uiClassID = "MenuItemUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /* diagnostic aids -- should be false for production builds. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    private static final boolean TRACE =   false; // trace creates and disposes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private static final boolean VERBOSE = false; // show reuse hits/misses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private static final boolean DEBUG =   false;  // show bad params, misc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private boolean isMouseDragged = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Creates a <code>JMenuItem</code> with no set text or icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public JMenuItem() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        this(null, (Icon)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * Creates a <code>JMenuItem</code> with the specified icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @param icon the icon of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public JMenuItem(Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        this(null, icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Creates a <code>JMenuItem</code> with the specified text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param text the text of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public JMenuItem(String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        this(text, (Icon)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Creates a menu item whose properties are taken from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * specified <code>Action</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param a the action of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public JMenuItem(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        this();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        setAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Creates a <code>JMenuItem</code> with the specified text and icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @param text the text of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @param icon the icon of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public JMenuItem(String text, Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        setModel(new DefaultButtonModel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        init(text, icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        initFocusability();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * Creates a <code>JMenuItem</code> with the specified text and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * keyboard mnemonic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @param text the text of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @param mnemonic the keyboard mnemonic for the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public JMenuItem(String text, int mnemonic) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        setModel(new DefaultButtonModel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        init(text, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        setMnemonic(mnemonic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        initFocusability();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public void setModel(ButtonModel newModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        super.setModel(newModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if(newModel instanceof DefaultButtonModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            ((DefaultButtonModel)newModel).setMenuItem(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
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
     * Inititalizes the focusability of the the <code>JMenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * <code>JMenuItem</code>'s are focusable, but subclasses may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * want to be, this provides them the opportunity to override this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * and invoke something else, or nothing at all. Refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * {@link javax.swing.JMenu#initFocusability} for the motivation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    void initFocusability() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        setFocusable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * Initializes the menu item with the specified text and icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @param text the text of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @param icon the icon of the <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    protected void init(String text, Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        if(text != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            setText(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        if(icon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            setIcon(icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        // Listen for Focus events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        addFocusListener(new MenuItemFocusListener());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        setUIProperty("borderPainted", Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        setFocusPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        setHorizontalTextPosition(JButton.TRAILING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        setHorizontalAlignment(JButton.LEADING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    private static class MenuItemFocusListener implements FocusListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        public void focusGained(FocusEvent event) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        public void focusLost(FocusEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            // When focus is lost, repaint if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            // the focus information is painted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            JMenuItem mi = (JMenuItem)event.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            if(mi.isFocusPainted()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                mi.repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            }
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
     * Sets the look and feel object that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @param ui  the <code>JMenuItemUI</code> L&F object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *    attribute: visualUpdate true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *  description: The UI object that implements the Component's LookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public void setUI(MenuItemUI ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * Resets the UI property with a value from the current look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        setUI((MenuItemUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
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
     * Returns the suffix used to construct the name of the L&F class used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * render this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @return the string "MenuItemUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
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
     * Identifies the menu item as "armed". If the mouse button is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * released while it is over this item, the menu's action event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * will fire. If the mouse button is released elsewhere, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * event will not fire and the menu item will be disarmed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @param b true to arm the menu item so it can be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *    description: Mouse release will fire an action event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *         hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    public void setArmed(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        ButtonModel model = (ButtonModel) getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        boolean oldValue = model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        if(model.isArmed() != b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            model.setArmed(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
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
     * Returns whether the menu item is "armed".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @return true if the menu item is armed, and it can be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @see #setArmed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    public boolean isArmed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        ButtonModel model = (ButtonModel) getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        return model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Enables or disables the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @param b  true to enable the item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *    description: Does the component react to user interaction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *          bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *      preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        // Make sure we aren't armed!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        if (!b && !UIManager.getBoolean("MenuItem.disabledAreNavigable")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            setArmed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        super.setEnabled(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    }
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
     * Returns true since <code>Menu</code>s, by definition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * should always be on top of all other windows.  If the menu is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * in an internal frame false is returned due to the rollover effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * for windows laf where the menu is not always on top.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    // package private
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    boolean alwaysOnTop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        // Fix for bug #4482165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        if (SwingUtilities.getAncestorOfClass(JInternalFrame.class, this) !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /* The keystroke which acts as the menu item's accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    private KeyStroke accelerator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * Sets the key combination which invokes the menu item's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * action listeners without navigating the menu hierarchy. It is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * UI's responsibility to install the correct action.  Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * when the keyboard accelerator is typed, it will work whether or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * not the menu is currently displayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @param keyStroke the <code>KeyStroke</code> which will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *          serve as an accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *     description: The keystroke combination which will invoke the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *                  JMenuItem's actionlisteners without navigating the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *                  menu hierarchy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *       preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    public void setAccelerator(KeyStroke keyStroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        KeyStroke oldAccelerator = accelerator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        this.accelerator = keyStroke;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        firePropertyChange("accelerator", oldAccelerator, accelerator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * Returns the <code>KeyStroke</code> which serves as an accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * for the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @return a <code>KeyStroke</code> object identifying the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     *          accelerator key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    public KeyStroke getAccelerator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return this.accelerator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    protected void configurePropertiesFromAction(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        super.configurePropertiesFromAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        configureAcceleratorFromAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    void setIconFromAction(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        Icon icon = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        if (a != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            icon = (Icon)a.getValue(Action.SMALL_ICON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        setIcon(icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    void largeIconChanged(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    void smallIconChanged(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        setIconFromAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    void configureAcceleratorFromAction(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        KeyStroke ks = (a==null) ? null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        setAccelerator(ks);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    protected void actionPropertyChanged(Action action, String propertyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        if (propertyName == Action.ACCELERATOR_KEY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            configureAcceleratorFromAction(action);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            super.actionPropertyChanged(action, propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        }
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
     * Processes a mouse event forwarded from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * <code>MenuSelectionManager</code> and changes the menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * selection, if necessary, by using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * <code>MenuSelectionManager</code>'s API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * Note: you do not have to forward the event to sub-components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * This is done automatically by the <code>MenuSelectionManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @param e   a <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * @param path  the <code>MenuElement</code> path array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * @param manager   the <code>MenuSelectionManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    public void processMouseEvent(MouseEvent e,MenuElement path[],MenuSelectionManager manager) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        processMenuDragMouseEvent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                 new MenuDragMouseEvent(e.getComponent(), e.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                        e.getWhen(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                                        e.getModifiers(), e.getX(), e.getY(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                                        e.getXOnScreen(), e.getYOnScreen(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                                        e.getClickCount(), e.isPopupTrigger(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                                        path, manager));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    }
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
     * Processes a key event forwarded from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * <code>MenuSelectionManager</code> and changes the menu selection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * if necessary, by using <code>MenuSelectionManager</code>'s API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * Note: you do not have to forward the event to sub-components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * This is done automatically by the <code>MenuSelectionManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @param e  a <code>KeyEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @param path the <code>MenuElement</code> path array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @param manager   the <code>MenuSelectionManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    public void processKeyEvent(KeyEvent e,MenuElement path[],MenuSelectionManager manager) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            System.out.println("in JMenuItem.processKeyEvent/3 for " + getText() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                                   "  " + KeyStroke.getKeyStrokeForEvent(e));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        MenuKeyEvent mke = new MenuKeyEvent(e.getComponent(), e.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                                             e.getWhen(), e.getModifiers(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                                             e.getKeyCode(), e.getKeyChar(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                                             path, manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        processMenuKeyEvent(mke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        if (mke.isConsumed())  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            e.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        }
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
     * Handles mouse drag in a menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @param e  a <code>MenuDragMouseEvent</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    public void processMenuDragMouseEvent(MenuDragMouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        switch (e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        case MouseEvent.MOUSE_ENTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            isMouseDragged = false; fireMenuDragMouseEntered(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        case MouseEvent.MOUSE_EXITED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            isMouseDragged = false; fireMenuDragMouseExited(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        case MouseEvent.MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            isMouseDragged = true; fireMenuDragMouseDragged(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        case MouseEvent.MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            if(isMouseDragged) fireMenuDragMouseReleased(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        }
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
     * Handles a keystroke in a menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @param e  a <code>MenuKeyEvent</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    public void processMenuKeyEvent(MenuKeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            System.out.println("in JMenuItem.processMenuKeyEvent for " + getText()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                                   "  " + KeyStroke.getKeyStrokeForEvent(e));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        switch (e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            fireMenuKeyPressed(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            fireMenuKeyReleased(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        case KeyEvent.KEY_TYPED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            fireMenuKeyTyped(e); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        }
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
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @param event a <code>MenuMouseDragEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    protected void fireMenuDragMouseEntered(MenuDragMouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            if (listeners[i]==MenuDragMouseListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                ((MenuDragMouseListener)listeners[i+1]).menuDragMouseEntered(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            }
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
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @param event a <code>MenuDragMouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    protected void fireMenuDragMouseExited(MenuDragMouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            if (listeners[i]==MenuDragMouseListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                ((MenuDragMouseListener)listeners[i+1]).menuDragMouseExited(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            }
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
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @param event a <code>MenuDragMouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    protected void fireMenuDragMouseDragged(MenuDragMouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            if (listeners[i]==MenuDragMouseListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                ((MenuDragMouseListener)listeners[i+1]).menuDragMouseDragged(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            }
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
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * @param event a <code>MenuDragMouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    protected void fireMenuDragMouseReleased(MenuDragMouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            if (listeners[i]==MenuDragMouseListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                ((MenuDragMouseListener)listeners[i+1]).menuDragMouseReleased(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            }
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
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * @param event a <code>MenuKeyEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    protected void fireMenuKeyPressed(MenuKeyEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            System.out.println("in JMenuItem.fireMenuKeyPressed for " + getText()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                                   "  " + KeyStroke.getKeyStrokeForEvent(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            if (listeners[i]==MenuKeyListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                ((MenuKeyListener)listeners[i+1]).menuKeyPressed(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            }
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
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * @param event a <code>MenuKeyEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    protected void fireMenuKeyReleased(MenuKeyEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            System.out.println("in JMenuItem.fireMenuKeyReleased for " + getText()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                                   "  " + KeyStroke.getKeyStrokeForEvent(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            if (listeners[i]==MenuKeyListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                ((MenuKeyListener)listeners[i+1]).menuKeyReleased(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            }
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
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @param event a <code>MenuKeyEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    protected void fireMenuKeyTyped(MenuKeyEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        if (DEBUG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            System.out.println("in JMenuItem.fireMenuKeyTyped for " + getText()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                                   "  " + KeyStroke.getKeyStrokeForEvent(event));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            if (listeners[i]==MenuKeyListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                ((MenuKeyListener)listeners[i+1]).menuKeyTyped(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            }
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
     * Called by the <code>MenuSelectionManager</code> when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * <code>MenuElement</code> is selected or unselected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * @param isIncluded  true if this menu item is on the part of the menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     *                    path that changed, false if this menu is part of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     *                    a menu path that changed, but this particular part of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     *                    that path is still the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * @see MenuSelectionManager#setSelectedPath(MenuElement[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    public void menuSelectionChanged(boolean isIncluded) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        setArmed(isIncluded);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * This method returns an array containing the sub-menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * components for this menu component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * @return an array of <code>MenuElement</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    public MenuElement[] getSubElements() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        return new MenuElement[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * Returns the <code>java.awt.Component</code> used to paint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * this object. The returned component will be used to convert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * events and detect if an event is inside a menu component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * @return the <code>Component</code> that paints this menu item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    public Component getComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * Adds a <code>MenuDragMouseListener</code> to the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @param l the <code>MenuDragMouseListener</code> to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    public void addMenuDragMouseListener(MenuDragMouseListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        listenerList.add(MenuDragMouseListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * Removes a <code>MenuDragMouseListener</code> from the menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * @param l the <code>MenuDragMouseListener</code> to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    public void removeMenuDragMouseListener(MenuDragMouseListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        listenerList.remove(MenuDragMouseListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * Returns an array of all the <code>MenuDragMouseListener</code>s added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * to this JMenuItem with addMenuDragMouseListener().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * @return all of the <code>MenuDragMouseListener</code>s added or an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     *         array if no listeners have been added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    public MenuDragMouseListener[] getMenuDragMouseListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        return (MenuDragMouseListener[])listenerList.getListeners(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                MenuDragMouseListener.class);
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() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        return (MenuKeyListener[])listenerList.getListeners(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                MenuKeyListener.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * See JComponent.readObject() for information about serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * Returns a string representation of this <code>JMenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * This method is intended to be used only for debugging purposes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * and the content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * @return  a string representation of this <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        return super.paramString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * Returns the <code>AccessibleContext</code> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * <code>JMenuItem</code>. For <code>JMenuItem</code>s,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * the <code>AccessibleContext</code> takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * <code>AccessibleJMenuItem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * A new AccessibleJMenuItme instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @return an <code>AccessibleJMenuItem</code> that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     *         <code>AccessibleContext</code> of this <code>JMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            accessibleContext = new AccessibleJMenuItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * <code>JMenuItem</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * Java Accessibility API appropriate to menu item user-interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     */
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
}