Class TriStateCheckBox

  • All Implemented Interfaces:
    ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

    @Deprecated
    public class TriStateCheckBox
    extends JCheckBox
    Deprecated.
    Use TriStateCheckBox.
    A checkbox with a "don't care" state. There were some tricks to getting this code working:
    1. You have to overwite addMouseListener() to do nothing
    2. You have to add a mouse event on mousePressed by calling super.addMouseListener()
    3. You have to replace the UIActionMap for the keyboard event "pressed" with your own one.
    4. You have to remove the UIActionMap for the keyboard event "released".
    5. You have to grab focus when the next state is entered, otherwise clicking on the component won't get the focus.
    6. You have to make a TristateDecorator as a button model that wraps the original button model and does state management.

    See Also:
    Java Specialists article, Serialized Form
    • Constructor Detail

      • TriStateCheckBox

        public TriStateCheckBox​(String pText)
        Deprecated.
      • TriStateCheckBox

        public TriStateCheckBox()
        Deprecated.
    • Method Detail

      • setState

        public void setState​(TriStateCheckBox.State pState)
        Deprecated.
        Set the new state. If state == null, it is treated as DONT_CARE_NOT_SELECTED.
      • getState

        public TriStateCheckBox.State getState()
        Deprecated.
        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

        protected TriStateCheckBox.State nextState()
        Deprecated.
        Override this method to chenge order of state iteration.