com.jidesoft.swing
Class TristateButtonModel
java.lang.Object
javax.swing.DefaultButtonModel
javax.swing.JToggleButton.ToggleButtonModel
com.jidesoft.swing.TristateButtonModel
- All Implemented Interfaces:
- ItemSelectable, Serializable, ButtonModel
public class TristateButtonModel
- extends JToggleButton.ToggleButtonModel
Model for TristateCheckBox. It introduces a mixed state to represent check box in the mixed selected state.
ActionEvent will be fired when the state is changed.
- See Also:
- Serialized Form
Field Summary |
static int |
MIXED
Identifies the "mixed" bit in the bitmask, which indicates that the button is partial selected. |
Fields inherited from class javax.swing.DefaultButtonModel |
actionCommand, ARMED, changeEvent, ENABLED, group, listenerList, mnemonic, PRESSED, ROLLOVER, SELECTED, stateMask |
Methods inherited from class javax.swing.DefaultButtonModel |
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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MIXED
public static final int MIXED
- Identifies the "mixed" bit in the bitmask, which indicates that the button is partial selected.
- See Also:
- Constant Field Values
TristateButtonModel
public TristateButtonModel()
setState
public void setState(int state)
getState
public int getState()
getNextState
protected int getNextState(int current)
- We rotate between STATE_UNSELECTED, STATE_SELECTED and STATE_MIXED. Subclass can override this method to tell the
check box what next state is. Here is the default implementation.
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;
}
- Parameters:
current
- the current state
- Returns:
- the next state of the current state.
setPressed
public void setPressed(boolean b)
- Specified by:
setPressed
in interface ButtonModel
- Overrides:
setPressed
in class JToggleButton.ToggleButtonModel
updateState
protected void updateState()
- Updates the state when the mouse is clicked. The default implementation is
setState(getNextState(getState()));
setSelected
public void setSelected(boolean b)
- Specified by:
setSelected
in interface ButtonModel
- Overrides:
setSelected
in class JToggleButton.ToggleButtonModel
isMixed
public boolean isMixed()
setMixed
public void setMixed(boolean b)