Java Reference
In-Depth Information
public interface ButtonModel extends ItemSelectable {
// Properties
public String getActionCommand();
public void setActionCommand(String newValue);
public boolean isArmed();
public void setArmed(boolean newValue);
public boolean isEnabled();
public void setEnabled(boolean newValue);
public void setGroup(ButtonGroup newValue);
public int getMnemonic();
public void setMnemonic(int newValue);
public boolean isPressed();
public void setPressed(boolean newValue);
public boolean isRollover();
public void setRollover(boolean newValue);
public boolean isSelected();
public void setSelected(boolean newValue);
// Listeners
public void addActionListener(ActionListener listener);
public void removeActionListener(ActionListener listener);
public void addChangeListener(ChangeListener listener);
public void removeChangeListener(ChangeListener listener);
public void addItemListener(ItemListener listener);
public void removeItemListener(ItemListener listener);
}
The specific implementation of ButtonModel you'll use, unless you create your own, is the
DefaultButtonModel class. The DefaultButtonModel class defines all the event registration
methods for the different event listeners and manages the button state and grouping within
a ButtonGroup . Its set of nine properties is shown in Table 4-12. They all come from the
ButtonGroup interface, except selectedObjects , which is new to the DefaultButtonModel class,
but more useful to the JToggleButton.ToggleButtonModel , which is discussed in Chapter 5.
Table 4-12. DefaultButtonModel Properties
Property Name
Data Type
Access
actionCommand
String
Read-write
armed
boolean
Read-write
enabled
boolean
Read-write
group
ButtonGroup
Read-write
mnemonic
int
Read-write
pressed
boolean
Read-write
rollover
boolean
Read-write
selected
boolean
Read-write
selectedObjects
Object[ ]
Read-only
Search WWH ::




Custom Search