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 express permission from the author, 2019.
- Author:
- Heinz M. Kabutz, Björn Darri Sigurðsson
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class javax.swing.DefaultButtonModel
actionCommand, ARMED, changeEvent, ENABLED, group, listenerList, mnemonic, PRESSED, ROLLOVER, SELECTED, stateMask
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static NullableToggleButtonModel
Instantiates a newNullableToggleButtonModel
with a null initial state.static NullableToggleButtonModel
nullableToggleButtonModel
(@Nullable Boolean initialState) Instantiates a newNullableToggleButtonModel
with the given initial state.void
setSelected
(boolean selected) Sets the underlying state to true or falsestate()
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, setPressed, setRollover
-
Field Details
-
NULL
public static final int NULLThe item state NULL.- See Also:
-
-
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
-
state
- Returns:
- the toggle state
-
nullableToggleButtonModel
Instantiates a newNullableToggleButtonModel
with a null initial state. -
nullableToggleButtonModel
Instantiates a newNullableToggleButtonModel
with the given initial state.- Parameters:
initialState
- the initial state
-