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
Action
s. 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)Action Creates 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. |
private JToggleButton | |
public String | Returns: the string "ToggleButtonUI"Overrides javax. |
protected String | Returns: a string representation of this JToggleButton.Overrides javax. |
public void | requestFocus(FocusEvent.
the cause why the focus is requested causeOverrides java. ButtonGroup which has
another toggle button which is selected and can be the focus owner,
and the focus cause argument denotes window activation or focus
traversal action of any direction the result of the method execution
is the same as calling
Component#requestFocus(FocusEvent. on the toggle button
selected in the group.
|
public boolean | requestFocusInWindow(FocusEvent.
the cause why the focus is requested causeOverrides java. ButtonGroup which has
another toggle button which is selected and can be the focus owner,
and the focus cause argument denotes window activation or focus
traversal action of any direction the result of the method execution
is the same as calling
Component#requestFocusInWindow(FocusEvent. on the toggle
button selected in the group.
|
private boolean | |
private void | |
pack-priv boolean | shouldUpdateSelectedStateFromAction()
Overrides javax. |
public void | updateUI()
Overrides javax. |
private void | writeObject(ObjectOutputStream
the s)
See readObject() and writeObject() in JComponent for more
information about serialization in Swing.
ObjectOutputStream in which to write |
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. |
public void | itemStateChanged(ItemEvent
the event to be processed e)Implements java. |
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. |
public void | setPressed(boolean
whether or not the button should be pressed b)Overrides javax. Implements javax. |
public void | setSelected(boolean
true selects the toggle button,
false deselects the toggle button. b)Overrides javax. Implements javax. |
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.
|