| java.lang.Object | |
| ↳ | javax.swing.DefaultButtonModel |
Known Direct Subclasses
|
The default implementation of a Button component's data 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 JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | ARMED | Identifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button. | |||||||||
| 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). | |||||||||
| int | PRESSED | Identifies the "pressed" bit in the bitmask, which indicates that the button is pressed. | |||||||||
| int | ROLLOVER | Identifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button. | |||||||||
| int | SELECTED | Identifies the "selected" bit in the bitmask, which indicates that the button has been selected. | |||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| actionCommand | The action command string fired by the button. | ||||||||||
| changeEvent | Only one ChangeEvent is needed per button model
instance since the event's only state is the source property. |
||||||||||
| group | The button group that the button belongs to. | ||||||||||
| listenerList | Stores the listeners on this model. | ||||||||||
| mnemonic | The button's mnemonic. | ||||||||||
| stateMask | The bitmask used to store the state of the button. | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a
DefaultButtonModel. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Adds an
ActionListener to the model.
| |||||||||||
Adds a
ChangeListener to the model.
| |||||||||||
Adds an
ItemListener to the model.
| |||||||||||
Returns the action command string for the button.
| |||||||||||
Returns an array of all the action listeners
registered on this
DefaultButtonModel. | |||||||||||
Returns an array of all the change listeners
registered on this
DefaultButtonModel. | |||||||||||
Returns the group that the button belongs to.
| |||||||||||
Returns an array of all the item listeners
registered on this
DefaultButtonModel. | |||||||||||
Returns an array of all the objects currently registered as
FooListeners
upon this model. | |||||||||||
Gets the keyboard mnemonic for the button.
| |||||||||||
Overridden to return
null. | |||||||||||
Indicates partial commitment towards triggering the
button.
| |||||||||||
Indicates if the button can be selected or triggered by
an input device, such as a mouse pointer.
| |||||||||||
Indicates if the button is pressed.
| |||||||||||
Indicates that the mouse is over the button.
| |||||||||||
Indicates if the button has been selected.
| |||||||||||
Removes an
ActionListener from the model.
| |||||||||||
Removes a
ChangeListener from the model.
| |||||||||||
Removes an
ItemListener from the model.
| |||||||||||
Sets the action command string that gets sent as part of the
ActionEvent when the button is triggered.
| |||||||||||
Marks the button as armed or unarmed.
| |||||||||||
Enables or disables the button.
| |||||||||||
Identifies the group the button belongs to --
needed for radio buttons, which are mutually
exclusive within their group.
| |||||||||||
Sets the keyboard mnemonic (shortcut key or
accelerator key) for the button.
| |||||||||||
Sets the button to pressed or unpressed.
| |||||||||||
Sets or clears the button's rollover state
| |||||||||||
Selects or deselects the button.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Notifies all listeners that have registered interest for
notification on this event type.
| |||||||||||
Notifies all listeners that have registered interest for
notification on this event type.
| |||||||||||
Notifies all listeners that have registered interest for
notification on this event type.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.awt.ItemSelectable
| |||||||||||
From interface
javax.swing.ButtonModel
| |||||||||||
Identifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button.
Identifies the "enabled" bit in the bitmask, which indicates that the button can be selected by an input device (such as a mouse pointer).
Identifies the "pressed" bit in the bitmask, which indicates that the button is pressed.
Identifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button.
Identifies the "selected" bit in the bitmask, which indicates that the button has been selected. Only needed for certain types of buttons - such as radio button or check box.
Only one ChangeEvent is needed per button model
instance since the event's only state is the source property.
The source of events generated is always "this".
The button's mnemonic.
The bitmask used to store the state of the button.
Constructs a DefaultButtonModel.
Adds an ActionListener to the model.
| l | the listener to add |
|---|
Adds a ChangeListener to the model.
| l | the listener to add |
|---|
Adds an ItemListener to the model.
| l | the listener to add |
|---|
Returns the action command string for the button.
String that identifies the generated eventReturns an array of all the action listeners
registered on this DefaultButtonModel.
ActionListeners
or an empty
array if no action listeners are currently registeredReturns an array of all the change listeners
registered on this DefaultButtonModel.
ChangeListeners
or an empty
array if no change listeners are currently registeredReturns the group that the button belongs to. Normally used with radio buttons, which are mutually exclusive within their group.
ButtonGroup that the button belongs toReturns an array of all the item listeners
registered on this DefaultButtonModel.
ItemListeners
or an empty
array if no item listeners are currently registeredReturns an array of all the objects currently registered as
FooListeners
upon this model.
FooListeners
are registered using the addFooListener method.
You can specify the listenerType argument
with a class literal, such as FooListener.class.
For example, you can query a DefaultButtonModel
instance m
for its action listeners
with the following code:
ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));If no such listeners exist, this method returns an empty array.
| listenerType | the type of listeners requested;
this parameter should specify an interface
that descends from java.util.EventListener |
|---|
FooListeners
on this model,
or an empty array if no such
listeners have been added| ClassCastException | if listenerType doesn't
specify a class or interface that implements
java.util.EventListener |
|---|
Gets the keyboard mnemonic for the button.
Indicates partial commitment towards triggering the button.
true if the button is armed,
and ready to be triggeredIndicates if the button can be selected or triggered by an input device, such as a mouse pointer.
true if the button is enabled
Indicates if the button is pressed.
true if the button is pressed
Indicates that the mouse is over the button.
true if the mouse is over the button
Indicates if the button has been selected. Only needed for certain types of buttons - such as radio buttons and check boxes.
true if the button is selected
Removes an ActionListener from the model.
| l | the listener to remove |
|---|
Removes a ChangeListener from the model.
| l | the listener to remove |
|---|
Removes an ItemListener from the model.
| l | the listener to remove |
|---|
Sets the action command string that gets sent as part of the
ActionEvent when the button is triggered.
| actionCommand | the String that identifies the generated event |
|---|
Marks the button as armed or unarmed.
| b | whether or not the button should be armed |
|---|
Enables or disables the button.
| b | whether or not the button should be enabled |
|---|
Identifies the group the button belongs to -- needed for radio buttons, which are mutually exclusive within their group.
| group | the ButtonGroup the button belongs to
|
|---|
Sets the keyboard mnemonic (shortcut key or accelerator key) for the button.
| key | an int specifying the accelerator key |
|---|
Sets the button to pressed or unpressed.
| b | whether or not the button should be pressed |
|---|
Sets or clears the button's rollover state
| b | whether or not the button is in the rollover state |
|---|
Selects or deselects the button.
| b | true selects the button,
false deselects the button
|
|---|
Notifies all listeners that have registered interest for notification on this event type.
| e | the ActionEvent to deliver to listeners |
|---|
Notifies all listeners that have registered interest for notification on this event type.
| e | the ItemEvent to deliver to listeners |
|---|
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.