Class JToggleButton.ToggleButtonModel
- All Implemented Interfaces:
ItemSelectable, Serializable, ButtonModel
- Enclosing class:
JToggleButton
public static class JToggleButton.ToggleButtonModel extends DefaultButtonModel
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 XMLEncoder.
- Since:
- 1.2
Field Summary
Fields declared in class DefaultButtonModel
actionCommand, ARMED, changeEvent, ENABLED, group, listenerList, mnemonic, PRESSED, ROLLOVER, SELECTED, stateMask | Modifier and Type | Field | Description |
|---|---|---|
protected String |
actionCommand |
The action command string fired by the button. |
static final int |
ARMED |
Identifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button. |
protected ChangeEvent |
changeEvent |
Only one ChangeEvent is needed per button model instance since the event's only state is the source property. |
static final int |
ENABLED |
Identifies the "enabled" bit in the bitmask, which indicates that the button can be selected by an input device (such as a mouse pointer). |
protected ButtonGroup |
group |
The button group that the button belongs to. |
protected EventListenerList |
listenerList |
Stores the listeners on this model. |
protected int |
mnemonic |
The button's mnemonic. |
static final int |
PRESSED |
Identifies the "pressed" bit in the bitmask, which indicates that the button is pressed. |
static final int |
ROLLOVER |
Identifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button. |
static final int |
SELECTED |
Identifies the "selected" bit in the bitmask, which indicates that the button has been selected. |
protected int |
stateMask |
The bitmask used to store the state of the button. |
Constructor Summary
| Constructor | Description |
|---|---|
ToggleButtonModel() |
Creates a new ToggleButton Model |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
isSelected() |
Checks if the button is selected. |
void |
setPressed |
Sets the pressed state of the toggle button. |
void |
setSelected |
Sets the selected state of the button. |
Methods declared in class DefaultButtonModel
addActionListener, addChangeListener, addItemListener, fireActionPerformed, fireItemStateChanged, fireStateChanged, getActionCommand, getActionListeners, getChangeListeners, getGroup, getItemListeners, getListeners, getMnemonic, getSelectedObjects, isArmed, isEnabled, isPressed, isRollover, removeActionListener, removeChangeListener, removeItemListener, setActionCommand, setArmed, setEnabled, setGroup, setMnemonic, setRollover | Modifier and Type | Method | Description |
|---|---|---|
void |
addActionListener |
Adds an ActionListener to the model. |
void |
addChangeListener |
Adds a ChangeListener to the model. |
void |
addItemListener |
Adds an ItemListener to the model. |
protected void |
fireActionPerformed |
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireItemStateChanged |
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireStateChanged() |
Notifies all listeners that have registered interest for notification on this event type. |
String |
getActionCommand() |
Returns the action command string for the button. |
ActionListener[] |
getActionListeners() |
Returns an array of all the action listeners registered on this DefaultButtonModel. |
ChangeListener[] |
getChangeListeners() |
Returns an array of all the change listeners registered on this DefaultButtonModel. |
ButtonGroup |
getGroup() |
Returns the group that the button belongs to. |
ItemListener[] |
getItemListeners() |
Returns an array of all the item listeners registered on this DefaultButtonModel. |
<T extends EventListener> |
getListeners |
Returns an array of all the objects currently registered as FooListeners upon this model. |
int |
getMnemonic() |
Gets the keyboard mnemonic for the button. |
Object[] |
getSelectedObjects() |
Overridden to return null. |
boolean |
isArmed() |
Indicates partial commitment towards triggering the button. |
boolean |
isEnabled() |
Indicates if the button can be selected or triggered by an input device, such as a mouse pointer. |
boolean |
isPressed() |
Indicates if the button is pressed. |
boolean |
isRollover() |
Indicates that the mouse is over the button. |
void |
removeActionListener |
Removes an ActionListener from the model. |
void |
removeChangeListener |
Removes a ChangeListener from the model. |
void |
removeItemListener |
Removes an ItemListener from the model. |
void |
setActionCommand |
Sets the action command string that gets sent as part of the ActionEvent when the button is triggered. |
void |
setArmed |
Marks the button as armed or unarmed. |
void |
setEnabled |
Enables or disables the button. |
void |
setGroup |
Identifies the group the button belongs to -- needed for radio buttons, which are mutually exclusive within their group. |
void |
setMnemonic |
Sets the keyboard mnemonic (shortcut key or accelerator key) for the button. |
void |
setRollover |
Sets or clears the button's rollover state |
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
toString() |
Returns a string representation of the object. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
ToggleButtonModel
public ToggleButtonModel()
Method Details
isSelected
public boolean isSelected()
- Returns:
-
trueif the button is selected
setSelected
public void setSelected(boolean b)
- Parameters:
-
b- true selects the toggle button, false deselects the toggle button.
setPressed
public void setPressed(boolean b)
- Parameters:
-
b- whether or not the button should be pressed - See Also:
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.