| Method from javax.swing.DefaultButtonModel Detail: |
public void addActionListener(ActionListener l) {
listenerList.add(ActionListener.class, l);
}
Add an ActionListener to the model. Usually only called to subscribe an
AbstractButton's listener to the model. |
public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
}
Add a ChangeListener to the model. Usually only called to subscribe an
AbstractButton's listener to the model. |
public void addItemListener(ItemListener l) {
listenerList.add(ItemListener.class, l);
}
Add an ItemListener to the model. Usually only called to subscribe an
AbstractButton's listener to the model. |
protected void fireActionPerformed(ActionEvent e) {
ActionListener[] ll = getActionListeners();
for (int i = 0; i < ll.length; i++)
ll[i].actionPerformed(e);
}
Inform each ActionListener in the #listenerList that an
ActionEvent has occurred. This happens in response to the any change to
the #stateMask field which makes the enabled, armed and pressed
properties all simultaneously true. |
protected void fireItemStateChanged(ItemEvent e) {
ItemListener[] ll = getItemListeners();
for (int i = 0; i < ll.length; i++)
ll[i].itemStateChanged(e);
}
Inform each ItemListener in the #listenerList that an ItemEvent
has occurred. This happens in response to any change to the #stateMask field. |
protected void fireStateChanged() {
ChangeListener[] ll = getChangeListeners();
for (int i = 0; i < ll.length; i++)
ll[i].stateChanged(changeEvent);
}
Inform each ChangeListener in the #listenerList that a ChangeEvent
has occurred. This happens in response to the any change to a property
of the model. |
public String getActionCommand() {
return actionCommand;
}
Returns the current value of the model's "actionCommand" property. |
public ActionListener[] getActionListeners() {
return (ActionListener[]) listenerList.getListeners(ActionListener.class);
}
Returns all registered ActionListener objects. |
public ChangeListener[] getChangeListeners() {
return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
}
Returns all registered ChangeListener objects. |
public ButtonGroup getGroup() {
return group;
}
Returns the current value of the model's "group" property. |
public ItemListener[] getItemListeners() {
return (ItemListener[]) listenerList.getListeners(ItemListener.class);
}
Returns all registered ItemListener objects. |
public EventListener[] getListeners(Class listenerType) {
return listenerList.getListeners(listenerType);
}
Returns a specified class of listeners. |
public int getMnemonic() {
return mnemonic;
}
Get the value of the model's "mnemonic" property. |
public Object[] getSelectedObjects() {
return null;
}
|
public boolean isArmed() {
return (stateMask & ARMED) == ARMED;
}
Get the value of the model's "armed" property. |
public boolean isEnabled() {
return (stateMask & ENABLED) == ENABLED;
}
Get the value of the model's "enabled" property. |
public boolean isPressed() {
return (stateMask & PRESSED) == PRESSED;
}
Get the value of the model's "pressed" property. |
public boolean isRollover() {
return (stateMask & ROLLOVER) == ROLLOVER;
}
Get the value of the model's "rollover" property. |
public boolean isSelected() {
return (stateMask & SELECTED) == SELECTED;
}
Get the value of the model's "selected" property. |
public void removeActionListener(ActionListener l) {
listenerList.remove(ActionListener.class, l);
}
Remove an ActionListener to the model. Usually only called to unsubscribe
an AbstractButton's listener to the model. |
public void removeChangeListener(ChangeListener l) {
listenerList.remove(ChangeListener.class, l);
}
Remove a ChangeListener to the model. Usually only called to unsubscribe
an AbstractButton's listener to the model. |
public void removeItemListener(ItemListener l) {
listenerList.remove(ItemListener.class, l);
}
Remove an ItemListener to the model. Usually only called to unsubscribe
an AbstractButton's listener to the model. |
public void setActionCommand(String s) {
if (actionCommand != s)
{
actionCommand = s;
fireStateChanged();
}
}
Set the value of the model's "actionCommand" property. This property is
used as the "command" property of the ActionEvent fired from the
model. |
public void setArmed(boolean a) {
// if this call does not represent a CHANGE in state, then return
if ((a && isArmed()) || (!a && !isArmed()))
return;
// cannot change ARMED state unless button is enabled
if (!isEnabled())
return;
// make the change
if (a)
stateMask = stateMask | ARMED;
else
stateMask = stateMask & (~ARMED);
// notify interested ChangeListeners
fireStateChanged();
}
Set the value of the model's "armed" property. |
public void setEnabled(boolean e) {
// if this call does not represent a CHANGE in state, then return
if ((e && isEnabled()) || (!e && !isEnabled()))
return;
// make the change
if (e)
stateMask = stateMask | ENABLED;
else
stateMask = stateMask & (~ENABLED);
// notify interested ChangeListeners
fireStateChanged();
}
Set the value of the model's "enabled" property. |
public void setGroup(ButtonGroup g) {
if (group != g)
{
group = g;
fireStateChanged();
}
}
Set the value of the model's "group" property. The model is said to be a
member of the ButtonGroup held in its "group" property, and only
one model in a given group can have their "selected" property be
true at a time. |
public void setMnemonic(int key) {
if (mnemonic != key)
{
mnemonic = key;
fireStateChanged();
}
}
Set the value of the model's "mnemonic" property. |
public void setPressed(boolean p) {
// if this call does not represent a CHANGE in state, then return
if ((p && isPressed()) || (!p && !isPressed()))
return;
// cannot changed PRESSED state unless button is enabled
if (!isEnabled())
return;
// make the change
if (p)
stateMask = stateMask | PRESSED;
else
stateMask = stateMask & (~PRESSED);
// if button is armed and was released, fire action event
if (!p && isArmed())
fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
actionCommand));
// notify interested ChangeListeners
fireStateChanged();
}
Set the value of the model's "pressed" property. |
public void setRollover(boolean r) {
// if this call does not represent a CHANGE in state, then return
if ((r && isRollover()) || (!r && !isRollover()))
return;
// cannot set ROLLOVER property unless button is enabled
if (!isEnabled())
return;
// make the change
if (r)
stateMask = stateMask | ROLLOVER;
else
stateMask = stateMask & (~ROLLOVER);
// notify interested ChangeListeners
fireStateChanged();
}
Set the value of the model's "rollover" property. |
public void setSelected(boolean s) {
// if this call does not represent a CHANGE in state, then return
if ((s && isSelected()) || (!s && !isSelected()))
return;
// make the change
if (s)
stateMask = stateMask | SELECTED;
else
stateMask = stateMask & (~SELECTED);
// notify interested ChangeListeners
fireStateChanged();
// fire ItemStateChanged events
if (s)
{
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
null, ItemEvent.SELECTED));
if (group != null)
group.setSelected(this, true);
}
else
{
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
null, ItemEvent.DESELECTED));
if (group != null)
group.setSelected(this, false);
}
}
Set the value of the model's "selected" property. |