public class TristateButtonModel extends JToggleButton.ToggleButtonModel
Modifier and Type | Field and Description |
---|---|
static int |
MIXED
Identifies the "mixed" bit in the bitmask, which indicates that the button is partial selected.
|
actionCommand, ARMED, changeEvent, ENABLED, group, listenerList, mnemonic, PRESSED, ROLLOVER, SELECTED, stateMask
Constructor and Description |
---|
TristateButtonModel() |
Modifier and Type | Method and Description |
---|---|
protected int |
getNextState(int current)
We rotate between STATE_UNSELECTED, STATE_SELECTED and STATE_MIXED.
|
int |
getState() |
boolean |
isMixed() |
void |
setMixed(boolean b) |
void |
setPressed(boolean b) |
void |
setSelected(boolean b) |
void |
setState(int state) |
protected void |
updateState()
Updates the state when the mouse is clicked.
|
isSelected
addActionListener, addChangeListener, addItemListener, fireActionPerformed, fireItemStateChanged, fireStateChanged, getActionCommand, getActionListeners, getChangeListeners, getGroup, getItemListeners, getListeners, getMnemonic, getSelectedObjects, isArmed, isEnabled, isPressed, isRollover, removeActionListener, removeChangeListener, removeItemListener, setActionCommand, setArmed, setEnabled, setGroup, setMnemonic, setRollover
public static final int MIXED
public void setState(int state)
public int getState()
protected int getNextState(int current)
if (current == TristateCheckBox.STATE_UNSELECTED) {
return TristateCheckBox.STATE_SELECTED;
}
else if (current == TristateCheckBox.STATE_SELECTED) {
return TristateCheckBox.STATE_MIXED;
}
else if (current == TristateCheckBox.STATE_MIXED) {
return TristateCheckBox.STATE_UNSELECTED;
}
current
- the current statepublic void setPressed(boolean b)
setPressed
in interface ButtonModel
setPressed
in class JToggleButton.ToggleButtonModel
protected void updateState()
setState(getNextState(getState()));
public void setSelected(boolean b)
setSelected
in interface ButtonModel
setSelected
in class JToggleButton.ToggleButtonModel
public boolean isMixed()
public void setMixed(boolean b)