Module is.codion.swing.common.model
Class NullableToggleButtonModel
java.lang.Object
javax.swing.DefaultButtonModel
is.codion.swing.common.model.component.button.NullableToggleButtonModel
- All Implemented Interfaces:
ItemSelectable
,Serializable
,ButtonModel
A ToggleButtonModel implementation, which allows the null state.
The states are null -> false -> true.
Heavily influenced by TristateCheckBox by Heinz M. Kabutz
http://www.javaspecialists.eu/archive/Issue145.html
Included with permission.
- See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class javax.swing.DefaultButtonModel
actionCommand, ARMED, changeEvent, ENABLED, group, listenerList, mnemonic, PRESSED, ROLLOVER, SELECTED, stateMask
-
Constructor Summary
ConstructorDescriptionInstantiates a newNullableToggleButtonModel
with a null initial state.NullableToggleButtonModel
(Boolean initialState) Instantiates a newNullableToggleButtonModel
with the given initial state. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
setSelected
(boolean selected) Sets the underlying state to true or falseMethods 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, setPressed, setRollover
-
Field Details
-
NULL
public static final int NULLThe item state NULL.
-
-
Constructor Details
-
NullableToggleButtonModel
public NullableToggleButtonModel()Instantiates a newNullableToggleButtonModel
with a null initial state. -
NullableToggleButtonModel
Instantiates a newNullableToggleButtonModel
with the given initial state.- Parameters:
initialState
- the initial state
-
-
Method Details
-
isSelected
public boolean isSelected()- Specified by:
isSelected
in interfaceButtonModel
- Overrides:
isSelected
in classDefaultButtonModel
- Returns:
- true if the underlying state is true
-
setSelected
public void setSelected(boolean selected) Sets the underlying state to true or false- Specified by:
setSelected
in interfaceButtonModel
- Overrides:
setSelected
in classDefaultButtonModel
- Parameters:
selected
- the new state
-
toggleState
- Returns:
- a
Mutable
controlling the toggle state
-