TristateCheckBox.TristateDecorator

gui

## Class TristateCheckBox.TristateDecorator

- java.lang.Object
- - gui.TristateCheckBox.TristateDecorator

- All Implemented Interfaces:
    java.awt.ItemSelectable, javax.swing.ButtonModel
  Enclosing class:
    TristateCheckBox

      private class TristateCheckBox.TristateDecorator
      extends java.lang.Object
      implements javax.swing.ButtonModel

  Exactly which Design Pattern is this? Is it an Adapter, a Proxy or a Decorator? In this case, my vote lies with the Decorator, because we are extending functionality and "decorating" the original model with a more powerful model.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private javax.swing.ButtonModel` | `other`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `TristateCheckBox.TristateDecorator(javax.swing.ButtonModel other)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addActionListener(java.awt.event.ActionListener l)`
    `void` | `addChangeListener(javax.swing.event.ChangeListener l)`
    `void` | `addItemListener(java.awt.event.ItemListener l)`
    `java.lang.String` | `getActionCommand()`
    `int` | `getMnemonic()`
    `java.lang.Object[]` | `getSelectedObjects()`
    `private TristateCheckBox.State` | `getState()` The current state is embedded in the selection / armed state of the model.
    `boolean` | `isArmed()` All these methods simply delegate to the "other" model that is being decorated.
    `boolean` | `isEnabled()`
    `boolean` | `isPressed()`
    `boolean` | `isRollover()`
    `boolean` | `isSelected()`
    `private void` | `nextState()` We rotate between NOT_SELECTED, SELECTED and DONT_CARE.
    `void` | `removeActionListener(java.awt.event.ActionListener l)`
    `void` | `removeChangeListener(javax.swing.event.ChangeListener l)`
    `void` | `removeItemListener(java.awt.event.ItemListener l)`
    `void` | `setActionCommand(java.lang.String s)`
    `void` | `setArmed(boolean b)` Filter: No one may change the armed status except us.
    `void` | `setEnabled(boolean b)` We disable focusing on the component when it is not enabled.
    `void` | `setGroup(javax.swing.ButtonGroup group)`
    `void` | `setMnemonic(int key)`
    `void` | `setPressed(boolean b)`
    `void` | `setRollover(boolean b)`
    `void` | `setSelected(boolean b)`
    `private void` | `setState(TristateCheckBox.State state)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### other

          private final javax.swing.ButtonModel other

  - ### Constructor Detail

    - #### TristateCheckBox.TristateDecorator

          private TristateCheckBox.TristateDecorator(javax.swing.ButtonModel other)

  - ### Method Detail

    - #### setState

          private void setState(TristateCheckBox.State state)

    - #### getState

          private TristateCheckBox.State getState()

      The current state is embedded in the selection / armed state of the model. We return the SELECTED state when the checkbox is selected but not armed, DONT_CARE state when the checkbox is selected and armed (grey) and NOT_SELECTED when the checkbox is deselected.

    - #### nextState

          private void nextState()

      We rotate between NOT_SELECTED, SELECTED and DONT_CARE.

    - #### setArmed

          public void setArmed(boolean b)

      Filter: No one may change the armed status except us.
      Specified by:
        `setArmed` in interface `javax.swing.ButtonModel`

    - #### setEnabled

          public void setEnabled(boolean b)

      We disable focusing on the component when it is not enabled.
      Specified by:
        `setEnabled` in interface `javax.swing.ButtonModel`

    - #### isArmed

          public boolean isArmed()

      All these methods simply delegate to the "other" model that is being decorated.
      Specified by:
        `isArmed` in interface `javax.swing.ButtonModel`

    - #### isSelected

          public boolean isSelected()

      Specified by:
        `isSelected` in interface `javax.swing.ButtonModel`

    - #### isEnabled

          public boolean isEnabled()

      Specified by:
        `isEnabled` in interface `javax.swing.ButtonModel`

    - #### isPressed

          public boolean isPressed()

      Specified by:
        `isPressed` in interface `javax.swing.ButtonModel`

    - #### isRollover

          public boolean isRollover()

      Specified by:
        `isRollover` in interface `javax.swing.ButtonModel`

    - #### setSelected

          public void setSelected(boolean b)

      Specified by:
        `setSelected` in interface `javax.swing.ButtonModel`

    - #### setPressed

          public void setPressed(boolean b)

      Specified by:
        `setPressed` in interface `javax.swing.ButtonModel`

    - #### setRollover

          public void setRollover(boolean b)

      Specified by:
        `setRollover` in interface `javax.swing.ButtonModel`

    - #### setMnemonic

          public void setMnemonic(int key)

      Specified by:
        `setMnemonic` in interface `javax.swing.ButtonModel`

    - #### getMnemonic

          public int getMnemonic()

      Specified by:
        `getMnemonic` in interface `javax.swing.ButtonModel`

    - #### setActionCommand

          public void setActionCommand(java.lang.String s)

      Specified by:
        `setActionCommand` in interface `javax.swing.ButtonModel`

    - #### getActionCommand

          public java.lang.String getActionCommand()

      Specified by:
        `getActionCommand` in interface `javax.swing.ButtonModel`

    - #### setGroup

          public void setGroup(javax.swing.ButtonGroup group)

      Specified by:
        `setGroup` in interface `javax.swing.ButtonModel`

    - #### addActionListener

          public void addActionListener(java.awt.event.ActionListener l)

      Specified by:
        `addActionListener` in interface `javax.swing.ButtonModel`

    - #### removeActionListener

          public void removeActionListener(java.awt.event.ActionListener l)

      Specified by:
        `removeActionListener` in interface `javax.swing.ButtonModel`

    - #### addItemListener

          public void addItemListener(java.awt.event.ItemListener l)

      Specified by:
        `addItemListener` in interface `java.awt.ItemSelectable`
      Specified by:
        `addItemListener` in interface `javax.swing.ButtonModel`

    - #### removeItemListener

          public void removeItemListener(java.awt.event.ItemListener l)

      Specified by:
        `removeItemListener` in interface `java.awt.ItemSelectable`
      Specified by:
        `removeItemListener` in interface `javax.swing.ButtonModel`

    - #### addChangeListener

          public void addChangeListener(javax.swing.event.ChangeListener l)

      Specified by:
        `addChangeListener` in interface `javax.swing.ButtonModel`

    - #### removeChangeListener

          public void removeChangeListener(javax.swing.event.ChangeListener l)

      Specified by:
        `removeChangeListener` in interface `javax.swing.ButtonModel`

    - #### getSelectedObjects

          public java.lang.Object[] getSelectedObjects()

      Specified by:
        `getSelectedObjects` in interface `java.awt.ItemSelectable`