| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public class DefaultButtonModel extends Object implements ButtonModel, 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 {@link java.beans.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 partial commitment towards choosing/triggering the button. |
protected transient 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 that the button can be selected by an input device (such as a mouse pointer). |
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 the "pressed" bit in the bitmask, which indicates that the button is pressed. |
static int |
ROLLOVER
Identifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button. |
static int |
SELECTED
Identifies the "selected" bit in the bitmask, which indicates that the button has been selected. |
protected int |
stateMask
The bitmask used to store the state of the button. |
Constructor Summary | |
---|---|
Constructs a DefaultButtonModel .
|
Method Summary | |
---|---|
void |
|
void |
|
void |
|
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. |
String |
|
ActionListener[] |
Returns an array of all the action listeners registered on this DefaultButtonModel .
|
ChangeListener[] |
Returns an array of all the change listeners registered on this DefaultButtonModel .
|
ButtonGroup |
getGroup() Returns the group that the button belongs to. |
ItemListener[] |
Returns an array of all the item listeners registered on this DefaultButtonModel .
|
EventListener[] |
getListeners(Class listenerType) Returns an array of all the objects currently registered as FooListener s
upon this model.
|
int |
|
Object[] |
Overridden to return null .
|
boolean |
isArmed() |
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
setActionCommand(String actionCommand) |
void |
setArmed(boolean b) |
void |
setEnabled(boolean b) |
void |
setGroup(ButtonGroup group) |
void |
setMnemonic(int key) |
void |
setPressed(boolean b) |
void |
setRollover(boolean b) |
void |
setSelected(boolean b) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String actionCommand
public static final int ARMED
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".
public static final int ENABLED
protected ButtonGroup group
protected EventListenerList listenerList
protected int mnemonic
public static final int PRESSED
public static final int ROLLOVER
public static final int SELECTED
protected int stateMask
Constructor Detail |
---|
public DefaultButtonModel()
DefaultButtonModel
.
Method Detail |
---|
public void addActionListener(ActionListener l)
l
public void addChangeListener(ChangeListener l)
l
public void addItemListener(ItemListener l)
l
protected void fireActionPerformed(ActionEvent e)
e
- the ActionEvent
to deliver to listenersprotected void fireItemStateChanged(ItemEvent e)
e
- the ItemEvent
to deliver to listenersprotected void fireStateChanged()
public String getActionCommand()
public ActionListener[] getActionListeners()
DefaultButtonModel
.
ActionListener
s
or an empty
array if no action listeners are currently registeredpublic ChangeListener[] getChangeListeners()
DefaultButtonModel
.
ChangeListener
s
or an empty
array if no change listeners are currently registeredpublic ButtonGroup getGroup()
ButtonGroup
that the button belongs topublic ItemListener[] getItemListeners()
DefaultButtonModel
.
ItemListener
s
or an empty
array if no item listeners are currently registeredpublic EventListener[] getListeners(Class listenerType)
FooListener
s
upon this model.
FooListener
s
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
FooListener
s
on this model,
or an empty array if no such
listeners have been addedpublic int getMnemonic()
public Object[] getSelectedObjects()
null
.
public boolean isArmed()
public boolean isEnabled()
public boolean isPressed()
public boolean isRollover()
public boolean isSelected()
public void removeActionListener(ActionListener l)
l
public void removeChangeListener(ChangeListener l)
l
public void removeItemListener(ItemListener l)
l
public void setActionCommand(String actionCommand)
actionCommand
public void setArmed(boolean b)
b
public void setEnabled(boolean b)
b
public void setGroup(ButtonGroup group)
group
public void setMnemonic(int key)
key
public void setPressed(boolean b)
b
public void setRollover(boolean b)
b
public void setSelected(boolean b)
b
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |