jdk/src/share/classes/javax/swing/JRadioButtonMenuItem.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * An implementation of a radio button menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * A <code>JRadioButtonMenuItem</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * a menu item that is part of a group of menu items in which only one
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * item in the group can be selected. The selected item displays its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * selected state. Selecting it causes any other selected item to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * switch to the unselected state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * To control the selected state of a group of radio button menu items,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * use a <code>ButtonGroup</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Menu items can be configured, and to some degree controlled, by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <code><a href="Action.html">Action</a></code>s.  Using an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <code>Action</code> with a menu item has many benefits beyond directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * configuring a menu item.  Refer to <a href="Action.html#buttonActions">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Swing Components Supporting <code>Action</code></a> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * details, and you can find more information in <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * href="http://java.sun.com/docs/books/tutorial/uiswing/misc/action.html">How
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * to Use Actions</a>, a section in <em>The Java Tutorial</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * For further documentation and examples see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 href="http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html">How to Use Menus</a>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * a section in <em>The Java Tutorial.</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *   attribute: isContainer false
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * description: A component within a group of menu items which can be selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * @author Georges Saab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * @author David Karlton
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * @see ButtonGroup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
public class JRadioButtonMenuItem extends JMenuItem implements Accessible {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static final String uiClassID = "RadioButtonMenuItemUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Creates a <code>JRadioButtonMenuItem</code> with no set text or icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public JRadioButtonMenuItem() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        this(null, null, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Creates a <code>JRadioButtonMenuItem</code> with an icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @param icon the <code>Icon</code> to display on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *          <code>JRadioButtonMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public JRadioButtonMenuItem(Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        this(null, icon, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Creates a <code>JRadioButtonMenuItem</code> with text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param text the text of the <code>JRadioButtonMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public JRadioButtonMenuItem(String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        this(text, null, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * Creates a radio button menu item whose properties are taken from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * <code>Action</code> supplied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param  a the <code>Action</code> on which to base the radio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *          button menu item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public JRadioButtonMenuItem(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        this();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        setAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Creates a radio button menu item with the specified text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * and <code>Icon</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @param text the text of the <code>JRadioButtonMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param icon the icon to display on the <code>JRadioButtonMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public JRadioButtonMenuItem(String text, Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        this(text, icon, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Creates a radio button menu item with the specified text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * and selection state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param text the text of the <code>CheckBoxMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param selected the selected state of the <code>CheckBoxMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public JRadioButtonMenuItem(String text, boolean selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        this(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        setSelected(selected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Creates a radio button menu item with the specified image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * and selection state, but no text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @param icon  the image that the button should display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @param selected  if true, the button is initially selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *                  otherwise, the button is initially unselected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public JRadioButtonMenuItem(Icon icon, boolean selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        this(null, icon, selected);
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
     * Creates a radio button menu item that has the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * text, image, and selection state.  All other constructors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * defer to this one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @param text  the string displayed on the radio button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @param icon  the image that the button should display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public JRadioButtonMenuItem(String text, Icon icon, boolean selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        super(text, icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        setModel(new JToggleButton.ToggleButtonModel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        setSelected(selected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        setFocusable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Returns the name of the L&F class that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @return the string "RadioButtonMenuItemUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * See <code>readObject</code> and <code>writeObject</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * <code>JComponent</code> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * information about serialization in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Returns a string representation of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <code>JRadioButtonMenuItem</code>.  This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @return  a string representation of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *          <code>JRadioButtonMenuItem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return super.paramString();
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
     * Overriden to return true, JRadioButtonMenuItem supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * the selected state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    boolean shouldUpdateSelectedStateFromAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Gets the AccessibleContext associated with this JRadioButtonMenuItem.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * For JRadioButtonMenuItems, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * AccessibleJRadioButtonMenuItem.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * A new AccessibleJRadioButtonMenuItem instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @return an AccessibleJRadioButtonMenuItem that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *         AccessibleContext of this JRadioButtonMenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            accessibleContext = new AccessibleJRadioButtonMenuItem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * <code>JRadioButtonMenuItem</code> class.  It provides an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * implementation of the Java Accessibility API appropriate to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * <code>JRadioButtonMenuItem</code> user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    protected class AccessibleJRadioButtonMenuItem extends AccessibleJMenuItem {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            return AccessibleRole.RADIO_BUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    } // inner class AccessibleJRadioButtonMenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
}