JRadioButton and JCheckBox classes
are subclasses of this class.
For information on using them see
How to Use Buttons, Check Boxes, and Radio Buttons,
a section in The Java Tutorial.
Buttons can be configured, and to some degree controlled, by
Actions. Using an
Action with a button has many benefits beyond directly
configuring a button. Refer to
Swing Components Supporting Action for more
details, and you can find more information in How
to Use Actions, a section in The Java Tutorial.
Warning
Swing is not thread safe. For more information see Swing's Threading Policy.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
JRadioButton, JCheckBox
| Modifier and Type | Class and Description |
|---|---|
| protected class | JToggleButton.
This class implements accessibility support for the
|
| public static class | JToggleButton.
The ToggleButton model Warning Serialized objects of this class will not be compatible with future Swing releases. |
| Modifier and Type | Field and Description |
|---|---|
| private static final String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | JToggleButton(Icon
the image that the button should display icon)Creates an initially unselected toggle button with the specified image but no text. |
| public | JToggleButton(Icon
the image that the button should display icon, boolean if true, the button is initially selected;
otherwise, the button is initially unselected selected)Creates a toggle button with the specified image and selection state, but no text. |
| public | JToggleButton(String
the string displayed on the toggle button text)Creates an unselected toggle button with the specified text. |
| public | JToggleButton(String
the string displayed on the toggle button text, boolean if true, the button is initially selected;
otherwise, the button is initially unselected selected)Creates a toggle button with the specified text and selection state. |
| public | JToggleButton(Action
an instance of an a)ActionCreates a toggle button where properties are taken from the Action supplied. |
| public | JToggleButton(String
the string displayed on the button text, Icon the image that the button should display icon)Creates a toggle button that has the specified text and image, and that is initially unselected. |
| public | JToggleButton(String
the text of the toggle button text, Icon the image that the button should display icon, boolean if true, the button is initially selected;
otherwise, the button is initially unselected selected)Creates a toggle button with the specified text, image, and selection state. |
| Modifier and Type | Method and Description |
|---|---|
| public AccessibleContext | Returns: an AccessibleJToggleButton that serves as the AccessibleContext of this JToggleButtonOverrides java. Implements javax. Gets the AccessibleContext associated with this JToggleButton. |
| private JToggleButton | |
| public String | Returns: the string "ToggleButtonUI"Overrides javax. Returns a string that specifies the name of the l&f class that renders this component. |
| protected String | Returns: a string representation of this JToggleButton.Overrides javax. Returns a string representation of this JToggleButton. |
| public void | requestFocus(FocusEvent.
the cause why the focus is requested causeOverrides java. If this toggle button is a member of the |
| public boolean | requestFocusInWindow(FocusEvent.
the cause why the focus is requested causeOverrides java. If this toggle button is a member of the |
| private boolean | |
| private void | |
| pack-priv boolean | shouldUpdateSelectedStateFromAction()
Overrides javax. Overridden to return true, JToggleButton supports the selected state. |
| public void | updateUI()
Overrides javax. Resets the UI property to a value from the current look and feel. |
| private void | writeObject(ObjectOutputStream s)
Hides javax. See readObject() and writeObject() in JComponent for more information about serialization in Swing. |
| uiClassID | back to summary |
|---|---|
| private static final String uiClassID Hides javax.
| |
| JToggleButton | back to summary |
|---|---|
| public JToggleButton() Creates an initially unselected toggle button without setting the text or image. | |
| JToggleButton | back to summary |
|---|---|
| public JToggleButton(Icon icon) Creates an initially unselected toggle button with the specified image but no text.
| |
| JToggleButton | back to summary |
|---|---|
| public JToggleButton(Icon icon, boolean selected) Creates a toggle button with the specified image and selection state, but no text.
| |
| JToggleButton | back to summary |
|---|---|
| public JToggleButton(String text) Creates an unselected toggle button with the specified text.
| |
| JToggleButton | back to summary |
|---|---|
| public JToggleButton(String text, boolean selected) Creates a toggle button with the specified text and selection state.
| |
| JToggleButton | back to summary |
|---|---|
| public JToggleButton(Action a) Creates a toggle button where properties are taken from the Action supplied.
| |
| JToggleButton | back to summary |
|---|---|
| public JToggleButton(String text, Icon icon) Creates a toggle button that has the specified text and image, and that is initially unselected. | |
| JToggleButton | back to summary |
|---|---|
| public JToggleButton(String text, Icon icon, boolean selected) Creates a toggle button with the specified text, image, and selection state. | |
| getAccessibleContext | back to summary |
|---|---|
| public AccessibleContext getAccessibleContext() Overrides java. Implements javax. Gets the AccessibleContext associated with this JToggleButton. For toggle buttons, the AccessibleContext takes the form of an AccessibleJToggleButton. A new AccessibleJToggleButton instance is created if necessary.
| |
| getGroupSelection | back to summary |
|---|---|
| private JToggleButton getGroupSelection(FocusEvent. | |
| getUIClassID | back to summary |
|---|---|
| public String getUIClassID() Overrides javax. Returns a string that specifies the name of the l&f class that renders this component.
| |
| paramString | back to summary |
|---|---|
| protected String paramString() Overrides javax. Returns a string representation of this JToggleButton. This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be
| |
| requestFocus | back to summary |
|---|---|
| public void requestFocus(FocusEvent. Overrides java. If this toggle button is a member of the
| |
| requestFocusInWindow | back to summary |
|---|---|
| public boolean requestFocusInWindow(FocusEvent. Overrides java. If this toggle button is a member of the
| |
| requestFocusInWindowUnconditionally | back to summary |
|---|---|
| private boolean requestFocusInWindowUnconditionally(FocusEvent. | |
| requestFocusUnconditionally | back to summary |
|---|---|
| private void requestFocusUnconditionally(FocusEvent. | |
| shouldUpdateSelectedStateFromAction | back to summary |
|---|---|
| pack-priv boolean shouldUpdateSelectedStateFromAction() Overrides javax. Overridden to return true, JToggleButton supports the selected state. | |
| updateUI | back to summary |
|---|---|
| public void updateUI() Overrides javax. Resets the UI property to a value from the current look and feel.
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException Hides javax. See readObject() and writeObject() in JComponent for more information about serialization in Swing.
| |
JToggleButton class. It provides an implementation of the
Java Accessibility API appropriate to toggle button user-interface
elements.Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public AccessibleRole | Returns: an instance of AccessibleRole describing the role of the objectOverrides javax. Get the role of this object. |
| public void | itemStateChanged(ItemEvent e)
Implements java. Fire accessible property change events when the state of the toggle button changes. |
| AccessibleJToggleButton | back to summary |
|---|---|
| public AccessibleJToggleButton() Constructs | |
| getAccessibleRole | back to summary |
|---|---|
| public AccessibleRole getAccessibleRole() Overrides javax. Get the role of this object.
| |
| itemStateChanged | back to summary |
|---|---|
| public void itemStateChanged(ItemEvent e) Implements java. Fire accessible property change events when the state of the toggle button changes. | |
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | isSelected()
Overrides javax. Implements javax. Checks if the button is selected. |
| public void | setPressed(boolean b)
Overrides javax. Implements javax. Sets the pressed state of the toggle button. |
| public void | setSelected(boolean
true selects the toggle button,
false deselects the toggle button. b)Overrides javax. Implements javax. Sets the selected state of the button. |
| ToggleButtonModel | back to summary |
|---|---|
| public ToggleButtonModel() Creates a new ToggleButton Model | |
| isSelected | back to summary |
|---|---|
| public boolean isSelected() Overrides javax. Implements javax. Checks if the button is selected. | |
| setPressed | back to summary |
|---|---|
| public void setPressed(boolean b) Overrides javax. Implements javax. Sets the pressed state of the toggle button.
| |
| setSelected | back to summary |
|---|---|
| public void setSelected(boolean b) Overrides javax. Implements javax. Sets the selected state of the button.
| |