javax.swing

Class JToggleButton

public class JToggleButton extends AbstractButton implements Accessible

The JToggleButton component provides a stateful button, which can be either selected or unselected. This provides the basis for the implementations of radio buttons (JRadioButton) and check boxes (JCheckBox).

Since: 1.2

See Also: JRadioButton JCheckBox

Nested Class Summary
protected classJToggleButton.AccessibleJToggleButton
This class provides accessibility support for the toggle button.
static classJToggleButton.ToggleButtonModel
The model handles the storage and maintenance of the state of the toggle button.
Constructor Summary
JToggleButton()
Constructs an unselected toggle button with no text or icon.
JToggleButton(Action a)
Constructs a toggle button using the labelling, state and icon specified by the supplied action.
JToggleButton(Icon icon)
Constructs an unselected toggle button with the supplied icon and no text.
JToggleButton(Icon icon, boolean selected)
Constructs a toggle button with the supplied icon and state.
JToggleButton(String text)
Constructs an unselected toggle button using the supplied text and no icon.
JToggleButton(String text, boolean selected)
Constructs a toggle button with the supplied text and state.
JToggleButton(String text, Icon icon)
Constructs an unselected toggle button with the supplied text and icon.
JToggleButton(String text, Icon icon, boolean selected)
Constructs a toggle button with the supplied text, icon and state.
Method Summary
AccessibleContextgetAccessibleContext()
Gets the AccessibleContext associated with this JToggleButton.
StringgetUIClassID()
Returns a string that specifies the name of the Look and Feel class that renders this component.
protected StringparamString()
Returns a textual representation of this component for debugging.
voidupdateUI()
This method resets the toggle button's UI delegate to the default UI for the current look and feel.

Constructor Detail

JToggleButton

public JToggleButton()
Constructs an unselected toggle button with no text or icon.

JToggleButton

public JToggleButton(Action a)
Constructs a toggle button using the labelling, state and icon specified by the supplied action.

Parameters: a the action to use to define the properties of the button.

JToggleButton

public JToggleButton(Icon icon)
Constructs an unselected toggle button with the supplied icon and no text.

Parameters: icon the icon to use.

JToggleButton

public JToggleButton(Icon icon, boolean selected)
Constructs a toggle button with the supplied icon and state.

Parameters: icon the icon to use. selected if true, the toggle button is initially in the selected state. Otherwise, the button is unselected.

JToggleButton

public JToggleButton(String text)
Constructs an unselected toggle button using the supplied text and no icon.

Parameters: text the text to use.

JToggleButton

public JToggleButton(String text, boolean selected)
Constructs a toggle button with the supplied text and state.

Parameters: text the text to use. selected if true, the toggle button is initially in the selected state. Otherwise, the button is unselected.

JToggleButton

public JToggleButton(String text, Icon icon)
Constructs an unselected toggle button with the supplied text and icon.

Parameters: text the text to use. icon the icon to use.

JToggleButton

public JToggleButton(String text, Icon icon, boolean selected)
Constructs a toggle button with the supplied text, icon and state.

Parameters: text the text to use. icon the icon to use. selected if true, the toggle button is initially in the selected state. Otherwise, the button is unselected.

Method Detail

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JToggleButton. The context is created, if necessary.

Returns: the associated context

getUIClassID

public String getUIClassID()
Returns a string that specifies the name of the Look and Feel class that renders this component.

Returns: The Look and Feel UI class in String form.

paramString

protected String paramString()
Returns a textual representation of this component for debugging. Users should not depend on anything as regards the content or formatting of this string, except for the fact that the returned string may never be null (only empty).

Returns: the component in String form for debugging.

updateUI

public void updateUI()
This method resets the toggle button's UI delegate to the default UI for the current look and feel.