jdk/src/share/classes/javax/swing/JRadioButton.java
author alexp
Fri, 02 Jul 2010 19:34:34 +0400
changeset 5956 e30f106a4b8b
parent 5506 202f599c92aa
child 20157 cafca01a8e28
permissions -rw-r--r--
6937415: Some components return undocumented default values under Nimbus LaF Reviewed-by: peterz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * An implementation of a radio button -- an item that can be selected or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * deselected, and which displays its state to the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Used with a {@link ButtonGroup} object to create a group of buttons
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * in which only one button at a time can be selected. (Create a ButtonGroup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * object and use its <code>add</code> method to include the JRadioButton objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * in the group.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <strong>Note:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * The ButtonGroup object is a logical grouping -- not a physical grouping.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * To create a button panel, you should still create a {@link JPanel} or similar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * container-object and add a {@link javax.swing.border.Border} to it to set it off from surrounding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Buttons can be configured, and to some degree controlled, by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <code><a href="Action.html">Action</a></code>s.  Using an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <code>Action</code> with a button has many benefits beyond directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * configuring a button.  Refer to <a href="Action.html#buttonActions">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Swing Components Supporting <code>Action</code></a> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * details, and you can find more information in <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * href="http://java.sun.com/docs/books/tutorial/uiswing/misc/action.html">How
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * to Use Actions</a>, a section in <em>The Java Tutorial</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * See <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/button.html">How to Use Buttons, Check Boxes, and Radio Buttons</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * in <em>The Java Tutorial</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * for further documentation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *   attribute: isContainer false
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * description: A component which can display it's state as selected or deselected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * @see ButtonGroup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * @see JCheckBox
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * @author Jeff Dinkins
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
public class JRadioButton extends JToggleButton implements Accessible {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    private static final String uiClassID = "RadioButtonUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Creates an initially unselected radio button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * with no set text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public JRadioButton () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        this(null, null, 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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Creates an initially unselected radio button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * with the specified image but no text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param icon  the image that the button should display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public JRadioButton(Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        this(null, icon, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Creates a radiobutton where properties are taken from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Action supplied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public JRadioButton(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        this();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        setAction(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Creates a radio button with the specified image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * and selection state, but no text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param icon  the image that the button should display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param selected  if true, the button is initially selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *                  otherwise, the button is initially unselected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public JRadioButton(Icon icon, boolean selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        this(null, icon, selected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Creates an unselected radio button with the specified text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @param text  the string displayed on the radio button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public JRadioButton (String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        this(text, null, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Creates a radio button with the specified text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * and selection state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @param text  the string displayed on the radio button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param selected  if true, the button is initially selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *                  otherwise, the button is initially unselected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public JRadioButton (String text, boolean selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        this(text, null, selected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Creates a radio button that has the specified text and image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * and that is initially unselected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @param text  the string displayed on the radio button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param icon  the image that the button should display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public JRadioButton(String text, Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        this(text, icon, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Creates a radio button that has the specified text, image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * and selection state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @param text  the string displayed on the radio button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @param icon  the image that the button should display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public JRadioButton (String text, Icon icon, boolean selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        super(text, icon, selected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        setBorderPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        setHorizontalAlignment(LEADING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Resets the UI property to a value from the current look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        setUI((ButtonUI)UIManager.getUI(this));
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Returns the name of the L&F class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @return String "RadioButtonUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *        expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *   description: A string that specifies the name of the L&F class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        return uiClassID;
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
     * The icon for radio buttons comes from the look and feel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * not the Action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    void setIconFromAction(Action a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * See readObject() and writeObject() in JComponent for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * information about serialization in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
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
     * Returns a string representation of this JRadioButton. This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @return  a string representation of this JRadioButton.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return super.paramString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
// Accessibility support
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
     * Gets the AccessibleContext associated with this JRadioButton.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * For JRadioButtons, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * AccessibleJRadioButton.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * A new AccessibleJRadioButton instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @return an AccessibleJRadioButton that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *         AccessibleContext of this JRadioButton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     *       expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *  description: The AccessibleContext associated with this Button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            accessibleContext = new AccessibleJRadioButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * <code>JRadioButton</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Java Accessibility API appropriate to radio button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    protected class AccessibleJRadioButton extends AccessibleJToggleButton {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
         * @return an instance of AccessibleRole describing the role of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            return AccessibleRole.RADIO_BUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    } // inner class AccessibleJRadioButton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
}