public final class NullableToggleButtonModel extends DefaultButtonModel
Modifier and Type | Field and Description |
---|---|
static int |
NULL
The item state NULL.
|
actionCommand, ARMED, changeEvent, ENABLED, group, listenerList, mnemonic, PRESSED, ROLLOVER, SELECTED, stateMask
Constructor and Description |
---|
NullableToggleButtonModel()
Instantiates a new
NullableToggleButtonModel with a null initial state. |
NullableToggleButtonModel(Boolean initialState)
Instantiates a new
NullableToggleButtonModel with the given initial state. |
Modifier and Type | Method and Description |
---|---|
void |
addStateListener(EventDataListener<Boolean> listener)
Adds a listener notified each time the state changes.
|
Boolean |
getState()
Returns the underlying value
|
boolean |
isSelected() |
void |
nextState()
Iterates between the states: null -> false -> true
|
void |
removeStateListener(EventDataListener<Boolean> listener)
Removes the given listener.
|
void |
setArmed(boolean armed)
Does nothing.
|
void |
setPressed(boolean pressed)
Does nothing.
|
void |
setSelected(boolean selected)
Sets the underlying state to true or false
|
void |
setState(Boolean state)
Sets the underlying state
|
addActionListener, addChangeListener, addItemListener, fireActionPerformed, fireItemStateChanged, fireStateChanged, getActionCommand, getActionListeners, getChangeListeners, getGroup, getItemListeners, getListeners, getMnemonic, getSelectedObjects, isArmed, isEnabled, isPressed, isRollover, removeActionListener, removeChangeListener, removeItemListener, setActionCommand, setEnabled, setGroup, setMnemonic, setRollover
public NullableToggleButtonModel()
NullableToggleButtonModel
with a null initial state.public NullableToggleButtonModel(Boolean initialState)
NullableToggleButtonModel
with the given initial state.initialState
- the initial statepublic boolean isSelected()
isSelected
in interface ButtonModel
isSelected
in class DefaultButtonModel
public void setSelected(boolean selected)
setSelected
in interface ButtonModel
setSelected
in class DefaultButtonModel
selected
- the new statepublic void setState(Boolean state)
state
- the statepublic Boolean getState()
public void nextState()
public void setArmed(boolean armed)
setArmed
in interface ButtonModel
setArmed
in class DefaultButtonModel
armed
- the valuepublic void setPressed(boolean pressed)
setPressed
in interface ButtonModel
setPressed
in class DefaultButtonModel
pressed
- the valuepublic void addStateListener(EventDataListener<Boolean> listener)
listener
- the listenerpublic void removeStateListener(EventDataListener<Boolean> listener)
listener
- the listener to remove