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, stateMaskModifier and TypeFieldDescriptionprotected StringThe action command string fired by the button.static final intIdentifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button.protected ChangeEventOnly oneChangeEventis needed per button model instance since the event's only state is the source property.static final intIdentifies the "enabled" bit in the bitmask, which indicates that the button can be selected by an input device (such as a mouse pointer).protected ButtonGroupThe button group that the button belongs to.protected EventListenerListStores the listeners on this model.protected intThe button's mnemonic.static final intIdentifies the "pressed" bit in the bitmask, which indicates that the button is pressed.static final intIdentifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button.static final intIdentifies the "selected" bit in the bitmask, which indicates that the button has been selected.protected intThe bitmask used to store the state of the button. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the button is selected.voidsetPressed(boolean b) Sets the pressed state of the toggle button.voidsetSelected(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, setRolloverModifier and TypeMethodDescriptionvoidAdds anActionListenerto the model.voidAdds aChangeListenerto the model.voidAdds anItemListenerto the model.protected voidNotifies all listeners that have registered interest for notification on this event type.protected voidNotifies all listeners that have registered interest for notification on this event type.protected voidNotifies 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 asFooListeners upon this model.intGets the keyboard mnemonic for the button.Object[]Overridden to returnnull.booleanisArmed()Indicates partial commitment towards triggering the button.booleanIndicates if the button can be selected or triggered by an input device, such as a mouse pointer.booleanIndicates if the button is pressed.booleanIndicates that the mouse is over the button.voidRemoves anActionListenerfrom the model.voidRemoves aChangeListenerfrom the model.voidRemoves anItemListenerfrom the model.voidsetActionCommand(String actionCommand) Sets the action command string that gets sent as part of theActionEventwhen the button is triggered.voidsetArmed(boolean b) Marks the button as armed or unarmed.voidsetEnabled(boolean b) Enables or disables the button.voidsetGroup(ButtonGroup group) Identifies the group the button belongs to -- needed for radio buttons, which are mutually exclusive within their group.voidsetMnemonic(int key) Sets the keyboard mnemonic (shortcut key or accelerator key) for the button.voidsetRollover(boolean b) Sets or clears the button's rollover stateMethods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
ToggleButtonModel
public ToggleButtonModel()Creates a new ToggleButton Model
-
-
Method Details
-
isSelected
public boolean isSelected()Checks if the button is selected.- Returns:
trueif 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:
-