Class JToggleButton.ToggleButtonModel
java.lang.Object
javax.swing.DefaultButtonModel
javax.swing.JToggleButton.ToggleButtonModel
- All Implemented Interfaces:
ItemSelectable, Serializable, ButtonModel
- Enclosing class:
JToggleButton
The ToggleButton model
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 TypeFieldDescriptionprotected String
The action command string fired by the button.static final int
Identifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button.protected ChangeEvent
Only oneChangeEvent
is needed per button model instance since the event's only state is the source property.static final int
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
The button group that the button belongs to.protected EventListenerList
Stores the listeners on this model.protected int
The button's mnemonic.static final int
Identifies the "pressed" bit in the bitmask, which indicates that the button is pressed.static final int
Identifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button.static final int
Identifies the "selected" bit in the bitmask, which indicates that the button has been selected.protected int
The bitmask used to store the state of the button. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the button is selected.void
setPressed
(boolean b) Sets the pressed state of the toggle button.void
setSelected
(boolean b) 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 TypeMethodDescriptionvoid
Adds anActionListener
to the model.void
Adds aChangeListener
to the model.void
Adds anItemListener
to the model.protected void
Notifies all listeners that have registered interest for notification on this event type.protected void
Notifies all listeners that have registered interest for notification on this event type.protected void
Notifies all listeners that have registered interest for notification on this event type.Returns the action command string for the button.Returns an array of all the action listeners registered on thisDefaultButtonModel
.Returns an array of all the change listeners registered on thisDefaultButtonModel
.getGroup()
Returns the group that the button belongs to.Returns an array of all the item listeners registered on thisDefaultButtonModel
.<T extends EventListener>
T[]getListeners
(Class<T> listenerType) Returns an array of all the objects currently registered asFooListener
s upon this model.int
Gets the keyboard mnemonic for the button.Object[]
Overridden to returnnull
.boolean
isArmed()
Indicates partial commitment towards triggering the button.boolean
Indicates if the button can be selected or triggered by an input device, such as a mouse pointer.boolean
Indicates if the button is pressed.boolean
Indicates that the mouse is over the button.void
Removes anActionListener
from the model.void
Removes aChangeListener
from the model.void
Removes anItemListener
from the model.void
setActionCommand
(String actionCommand) Sets the action command string that gets sent as part of theActionEvent
when the button is triggered.void
setArmed
(boolean b) Marks the button as armed or unarmed.void
setEnabled
(boolean b) Enables or disables the button.void
setGroup
(ButtonGroup group) Identifies the group the button belongs to -- needed for radio buttons, which are mutually exclusive within their group.void
setMnemonic
(int key) Sets the keyboard mnemonic (shortcut key or accelerator key) for the button.void
setRollover
(boolean b) Sets or clears the button's rollover stateMethods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
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 thisObject
.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
Wakes up all threads that are waiting on this object's monitor.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
(long timeoutMillis) 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
(long timeoutMillis, int nanos) 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()Creates a new ToggleButton Model
-
-
Method Details
-
isSelected
public boolean isSelected()Checks if the button is selected.- Returns:
true
if the button is selected
-
setSelected
public void setSelected(boolean b) Sets the selected state of the button.- Parameters:
b
- true selects the toggle button, false deselects the toggle button.
-
setPressed
public void setPressed(boolean b) Sets the pressed state of the toggle button.- Parameters:
b
- whether or not the button should be pressed- See Also:
-