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.
|
isSelectedaddActionListener, 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, setRolloverpublic 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 ButtonModelsetPressed in class JToggleButton.ToggleButtonModelprotected void updateState()
setState(getNextState(getState()));
public void setSelected(boolean b)
setSelected in interface ButtonModelsetSelected in class JToggleButton.ToggleButtonModelpublic boolean isMixed()
public void setMixed(boolean b)
Copyright © 2017. All rights reserved.