Java JToggleButton

JToggleButton is used to create toggle button, it is two-states button to switch on or off.

Nested Classes

Modifier and TypeClassDescription
protected classJToggleButton.AccessibleJToggleButtonThis class implements accessibility support for the JToggleButton class.
static classJToggleButton.ToggleButtonModelThe ToggleButton model

Constructors

ConstructorDescription
JToggleButton()It creates an initially unselected toggle button without setting the text or image.
JToggleButton(Action a)It creates a toggle button where properties are taken from the Action supplied.
JToggleButton(Icon icon)It creates an initially unselected toggle button with the specified image but no text.
JToggleButton(Icon icon, boolean selected)It creates a toggle button with the specified image and selection state, but no text.
JToggleButton(String text)It creates an unselected toggle button with the specified text.
JToggleButton(String text, boolean selected)It creates a toggle button with the specified text and selection state.
JToggleButton(String text, Icon icon)It creates a toggle button that has the specified text and image, and that is initially unselected.
JToggleButton(String text, Icon icon, boolean selected)It creates a toggle button with the specified text, image, and selection state.

Methods

Modifier and TypeMethodDescription
AccessibleContextgetAccessibleContext()It gets the AccessibleContext associated with this JToggleButton.
StringgetUIClassID()It returns a string that specifies the name of the l&f class that renders this component.
protected StringparamString()It returns a string representation of this JToggleButton.
voidupdateUI()It resets the UI property to a value from the current look and feel.

JToggleButton Example

Output

Java JTogglebutton
Next TopicJava JToolBar




Latest Courses