is new.
java.lang.Objectjavax.swing.DefaultButtonModel
public class DefaultButtonModel
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 JavaBeans TM has been added to the java.beans package. Please see XMLEncoder .
| Field Summary | |
|---|---|
| protected String |
actionCommand
The action command string fired by the button.
|
| static int |
ARMED
Identifies the "armed" bit in the bitmask, which indicates
choosing/triggering
|
| protected ChangeEvent |
changeEvent
Only one ChangeEvent is needed per button model instance since the event's only state is the source property. |
| static int |
ENABLED
Identifies the "enabled" bit in the bitmask, which indicates
|
| 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 int |
PRESSED
Identifies
bit in
bitmask, which indicates that the button
pressed.
|
| static int |
ROLLOVER
Identifies the "rollover" bit in the bitmask, which indicates
|
| static int |
SELECTED
Identifies the "selected" bit in the bitmask, which indicates
|
| protected int |
stateMask
The bitmask used to store the state of the button.
|
| Constructor Summary | |
|---|---|
|
DefaultButtonModel
() Constructs a
DefaultButtonModel.
|
|
| Method Summary | ||
|---|---|---|
| void |
addActionListener
(
ActionListener
Adds an ActionListener to the
model.
|
|
| void |
addChangeListener
(
ChangeListener
Adds a ChangeListener to the
model.
|
|
| void |
addItemListener
(
ItemListener
Adds
a listener
receive item events when
the
state of an item is changed by the user.
|
|
| protected void |
fireActionPerformed
(
ActionEvent
e) Notifies all listeners that have registered interest for notification on this event type. |
|
| protected void |
fireItemStateChanged
(
ItemEvent
e) 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
|
|
| 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
|
|
| ItemListener [] |
getItemListeners
() Returns an array of all the item listeners registered on this DefaultButtonModel. |
|
|
getListeners
(
Class
<T> listenerType) 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
|
|
| boolean |
isEnabled
() Indicates
if
triggered
device, such
pointer.
|
|
| boolean |
isPressed
() Indicates
if the
is
|
|
| boolean |
isRollover
() Indicates that the mouse is over the button. |
|
| boolean |
isSelected
() Indicates if the button has been selected. |
|
| void |
removeActionListener
(
ActionListener
Removes an ActionListener from the
model.
|
|
| void |
removeChangeListener
(
ChangeListener
Removes a ChangeListener from the
model.
|
|
| void |
removeItemListener
(
ItemListener
Removes an
item listener.
|
|
| void |
setActionCommand
(
String
Sets the
action command
ActionEvent
triggered.
|
|
| void |
setArmed
(boolean b) Marks the button as
armed or unarmed.
|
|
| void |
setEnabled
(boolean b) Enables or disables the button. |
|
| void |
setGroup
(
ButtonGroup
Identifies the group
the
|
|
| void |
setMnemonic
(int key) Sets the keyboard mnemonic (shortcut key or accelerator key) for
the
|
|
| void |
setPressed
(boolean b) Sets the button to pressed or unpressed. |
|
| void |
setRollover
(boolean b) Sets or clears the button's rollover state |
|
| void |
setSelected
(boolean b) Selects or deselects the button. |
|
| Methods inherited from class java.lang. Object |
|---|
| clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
| Field Detail |
|---|
protected int stateMask
The bitmask used to store the state of the button.
protected String actionCommand
The action command string fired by the button.
protected ButtonGroup group
The button group that the button belongs to.
protected int mnemonic
The button's mnemonic.
protected transient ChangeEvent changeEvent
protected EventListenerList listenerList
Stores the listeners on this model.
public static final int ARMED
Identifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button.
public static final int SELECTED
Identifies the "selected" bit in the bitmask, which indicates
radio button
check box.
public static final int PRESSED
Identifies the "pressed" bit in the bitmask, which indicates that the button is pressed.
public static final int ENABLED
Identifies the "enabled" bit in the bitmask, which indicates
public static final int ROLLOVER
Identifies the "rollover" bit in the bitmask, which indicates
| Constructor Detail |
|---|
public DefaultButtonModel()
DefaultButtonModel.
| Method Detail |
|---|
public void setActionCommand(String actionCommand)
Description copied from interface:
ButtonModel
action command
ActionEvent
triggered.
See Also:
ButtonModel.getActionCommand()
,
ActionEvent.getActionCommand()
public String getActionCommand()
Description copied from interface:
ButtonModel
Returns the action command string for the button.
ButtonModel.setActionCommand(java.lang.String)
public boolean isArmed()
Description copied from interface:
ButtonModel
triggering
triggered
ButtonModel.setArmed(boolean)
public boolean isSelected()
Description copied from interface:
ButtonModel
radio buttons and check boxes.
public boolean isEnabled()
Description copied from interface:
ButtonModel
Indicates if the button can be selected or triggered by an input device, such as a mouse pointer.
enabled
public boolean isPressed()
Description copied from interface:
ButtonModel
Indicates if the button is pressed.
is
public boolean isRollover()
Description copied from interface:
ButtonModel
public void setArmed(boolean b)
Description copied from interface:
ButtonModel
Marks the button as armed or unarmed.
b - whether or not the button should be armed
public void setEnabled(boolean b)
Description copied from interface:
ButtonModel
b - whether or not the button should be enabled
ButtonModel.isEnabled()
public void setSelected(boolean b)
Description copied from interface:
ButtonModel
public void setPressed(boolean b)
Description copied from interface:
ButtonModel
b - whether or not the button should be pressed
ButtonModel.isPressed()
public void setRollover(boolean b)
Description copied from interface:
ButtonModel
ButtonModel.isRollover()
public void setMnemonic(int key)
Description copied from interface:
ButtonModel
the
public int getMnemonic()
Description copied from interface:
ButtonModel
Gets the keyboard mnemonic for the button.
ButtonModel.setMnemonic(int)
public void addChangeListener(ChangeListener l)
Description copied from interface:
ButtonModel
Adds a ChangeListener to the model.
public void removeChangeListener(ChangeListener l)
Description copied from interface:
ButtonModel
Removes a ChangeListener from the model.
public ChangeListener[] getChangeListeners()
protected void fireStateChanged()
public void addActionListener(ActionListener l)
Description copied from interface:
ButtonModel
Adds an ActionListener to the model.
public void removeActionListener(ActionListener l)
Description copied from interface:
ButtonModel
Removes an ActionListener from the model.
public ActionListener[] getActionListeners()
protected void fireActionPerformed(ActionEvent e)
public void addItemListener(ItemListener l)
Description copied from interface:
ItemSelectable
Adds a listener to receive item events when the state of an item is changed by the user. Item events are not sent when an item's state is set programmatically. If l is null, no exception is thrown and no action is performed.
receive events
public void removeItemListener(ItemListener l)
Description copied from interface:
ItemSelectable
Removes an item listener. If l is null, no exception is thrown and no action is performed.
being removed
public ItemListener[] getItemListeners()
protected void fireItemStateChanged(ItemEvent e)
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
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.
public Object[] getSelectedObjects()
public void setGroup(ButtonGroup group)
Description copied from interface:
ButtonModel
the
the
public ButtonGroup getGroup()
the
the
the