|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
javax.swing.DefaultButtonModel
, Serializable
, ButtonModel


public class DefaultButtonModel

, Serializable

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
.
| Field Summary | |
|---|---|
protected String |
actionCommand
|
static int |
ARMED
Indicates partial commitment towards choosing 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 int |
ENABLED
Indicates that the button can be selected by an input device (such as a mouse pointer). |
protected ButtonGroup |
group
|
protected EventListenerList |
listenerList
|
protected int |
mnemonic
|
static int |
PRESSED
Indicates that the button has been "pressed" (typically, when the mouse is released). |
static int |
ROLLOVER
Indicates that the mouse is over the button. |
static int |
SELECTED
Indicates that the button has been selected. |
protected int |
stateMask
|
| Constructor Summary | |
|---|---|
DefaultButtonModel
Constructs a default JButtonModel. |
|
| Method Summary | ||
|---|---|---|
void |
addActionListener
Adds an ActionListener to the button. |
|
void |
addChangeListener
Adds a ChangeListener to the button. |
|
void |
addItemListener
Adds an ItemListener to the button. |
|
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 for this 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 this button belongs to. |
|
ItemListener |
getItemListeners
Returns an array of all the item listeners registered on this DefaultButtonModel. |
|
|
getListeners
Returns an array of all the objects currently registered as FooListeners
upon this model. |
|
int |
getMnemonic
Gets the keyboard mnemonic for this model |
|
Object |
getSelectedObjects
Overridden to return null. |
|
boolean |
isArmed
Indicates partial commitment towards pressing the button. |
|
boolean |
isEnabled
Indicates whether the button can be selected or pressed by an input device (such as a mouse pointer). |
|
boolean |
isPressed
Indicates whether button has been pressed. |
|
boolean |
isRollover
Indicates that the mouse is over the button. |
|
boolean |
isSelected
Indicates if the button has been selected. |
|
void |
removeActionListener
Removes an ActionListener from the button. |
|
void |
removeChangeListener
Removes a ChangeListener from the button. |
|
void |
removeItemListener
Removes an ItemListener from the button. |
|
void |
setActionCommand
Sets the actionCommand string that gets sent as
part of the event when the button is pressed. |
|
void |
setArmed
Marks the button as "armed". |
|
void |
setEnabled
Enables or disables the button. |
|
void |
setGroup
Identifies the group this 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 this button. |
|
void |
setPressed
Sets the button to pressed or unpressed. |
|
void |
setRollover
Sets or clears the button's rollover state |
|
void |
setSelected
Selects or deselects the button. |
|
Methods inherited from class java.lang.Object ![]() |
|---|
clone |
| Field Detail |
|---|

protected int stateMask

protected String![]()
![]()
actionCommand

protected ButtonGroup![]()
![]()
group

protected int mnemonic

protected transient ChangeEvent![]()
![]()
changeEvent
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".

protected EventListenerList![]()
![]()
listenerList

public static final int ARMED

public static final int SELECTED

public static final int PRESSED

public static final int ENABLED

public static final int ROLLOVER
| Constructor Detail |
|---|

public DefaultButtonModel()
JButtonModel.
| Method Detail |
|---|

public void setActionCommand(String![]()
![]()
actionCommand)
actionCommand string that gets sent as
part of the event when the button is pressed.
setActionCommand

in interface ButtonModel

actionCommand - the String that identifies
the generated event

public String![]()
![]()
getActionCommand()
getActionCommand

in interface ButtonModel

String that identifies the generated eventsetActionCommand(java.lang.String)


public boolean isArmed()
isArmed

in interface ButtonModel

setArmed(boolean)


public boolean isSelected()
isSelected

in interface ButtonModel


public boolean isEnabled()
isEnabled

in interface ButtonModel


public boolean isPressed()
isPressed

in interface ButtonModel


public boolean isRollover()
isRollover

in interface ButtonModel


public void setArmed(boolean b)
setArmed

in interface ButtonModel

b - true to arm the button so it can be selected

public void setEnabled(boolean b)
setEnabled

in interface ButtonModel

b - true to enable the buttonisEnabled()


public void setSelected(boolean b)
setSelected

in interface ButtonModel

b - true selects the button,
false deselects the button

public void setPressed(boolean b)
setPressed

in interface ButtonModel

b - true to set the button to "pressed"isPressed()


public void setRollover(boolean b)
setRollover

in interface ButtonModel

b - true to turn on rolloverisRollover()


public void setMnemonic(int key)
setMnemonic

in interface ButtonModel

key - an int specifying the accelerator key

public int getMnemonic()
getMnemonic

in interface ButtonModel

setMnemonic(int)


public void addChangeListener(ChangeListener![]()
![]()
l)
ChangeListener to the button.
addChangeListener

in interface ButtonModel

l - the listener to add

public void removeChangeListener(ChangeListener![]()
![]()
l)
ChangeListener from the button.
removeChangeListener

in interface ButtonModel

l - the listener to remove

public ChangeListener![]()
![]()
[] getChangeListeners()
DefaultButtonModel.
ChangeListeners
or an empty
array if no change listeners are currently registeredaddChangeListener(javax.swing.event.ChangeListener)
,
removeChangeListener(javax.swing.event.ChangeListener)


protected void fireStateChanged()
EventListenerList


public void addActionListener(ActionListener![]()
![]()
l)
ActionListener to the button.
addActionListener

in interface ButtonModel

l - the listener to add

public void removeActionListener(ActionListener![]()
![]()
l)
ActionListener from the button.
removeActionListener

in interface ButtonModel

l - the listener to remove

public ActionListener![]()
![]()
[] getActionListeners()
DefaultButtonModel.
ActionListeners
or an empty
array if no action listeners are currently registeredaddActionListener(java.awt.event.ActionListener)
,
removeActionListener(java.awt.event.ActionListener)


protected void fireActionPerformed(ActionEvent![]()
![]()
e)
e - the ActionEvent to deliver to listenersEventListenerList


public void addItemListener(ItemListener![]()
![]()
l)
ItemListener to the button.
addItemListener

in interface ItemSelectable

addItemListener

in interface ButtonModel

l - the listener to addItemEvent


public void removeItemListener(ItemListener![]()
![]()
l)
ItemListener from the button.
removeItemListener

in interface ItemSelectable

removeItemListener

in interface ButtonModel

l - the listener to removeItemEvent


public ItemListener![]()
![]()
[] getItemListeners()
DefaultButtonModel.
ItemListeners
or an empty
array if no item listeners are currently registeredaddItemListener(java.awt.event.ItemListener)
,
removeItemListener(java.awt.event.ItemListener)


protected void fireItemStateChanged(ItemEvent![]()
![]()
e)
e - the ItemEvent to deliver to listenersEventListenerList


public <T extends EventListener![]()
![]()
> T[] getListeners(Class
![]()
![]()
<T> listenerType)
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.EventListenergetActionListeners()
,
getChangeListeners()
,
getItemListeners()


public Object![]()
![]()
[] getSelectedObjects()
null.
getSelectedObjects

in interface ItemSelectable


public void setGroup(ButtonGroup![]()
![]()
group)
setGroup

in interface ButtonModel

group - the ButtonGroup this button belongs to

public ButtonGroup![]()
![]()
getGroup()
ButtonGroup that this button belongs to
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||