Class NullableToggleButtonModel

  • All Implemented Interfaces:
    ItemSelectable, Serializable, ButtonModel

    public final class NullableToggleButtonModel
    extends DefaultButtonModel
    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
    See Also:
    Serialized Form
    • Constructor Detail

      • NullableToggleButtonModel

        public NullableToggleButtonModel()
        Instantiates a new NullableToggleButtonModel with a null initial state.
      • NullableToggleButtonModel

        public NullableToggleButtonModel​(Boolean initialState)
        Instantiates a new NullableToggleButtonModel with the given initial state.
        Parameters:
        initialState - the initial state
    • Method Detail

      • setState

        public void setState​(Boolean state)
        Sets the underlying state
        Parameters:
        state - the state
      • getState

        public Boolean getState()
        Returns the underlying value
        Returns:
        the state
      • nextState

        public void nextState()
        Iterates between the states: null -> false -> true
      • addStateListener

        public void addStateListener​(EventDataListener<Boolean> listener)
        Adds a listener notified each time the state changes.
        Parameters:
        listener - the listener
      • removeStateListener

        public void removeStateListener​(EventDataListener<Boolean> listener)
        Removes the given listener.
        Parameters:
        listener - the listener to remove