com.alee.extended.checkbox
Class TristateCheckBoxModel

java.lang.Object
  extended by javax.swing.DefaultButtonModel
      extended by javax.swing.JToggleButton.ToggleButtonModel
          extended by com.alee.extended.checkbox.TristateCheckBoxModel
All Implemented Interfaces:
java.awt.ItemSelectable, java.io.Serializable, javax.swing.ButtonModel

public class TristateCheckBoxModel
extends javax.swing.JToggleButton.ToggleButtonModel

Custom button model for WebTristateCheckBox component.

Author:
Mikle Garin
See Also:
Serialized Form

Field Summary
protected  boolean checkMixedOnToggle
          Whether partially checked tristate checkbox should be checked or unchecked on toggle.
static int MIXED
          Mixed state bit constant used to store into state mask.
 
Fields inherited from class javax.swing.DefaultButtonModel
actionCommand, ARMED, changeEvent, ENABLED, group, listenerList, mnemonic, PRESSED, ROLLOVER, SELECTED, stateMask
 
Constructor Summary
TristateCheckBoxModel()
          Constructs new model for the specified WebTristateCheckBox.
 
Method Summary
protected  CheckState getNextState(CheckState checkState)
          Returns next check state for check invertion action.
 CheckState getState()
           
protected  void goToNextState()
          Applies next check state to this tristate checkbox according to its settings.
 boolean isCheckMixedOnToggle()
          Returns whether partially checked tristate checkbox should be checked or unchecked on toggle
 boolean isMixed()
          Returns whether checkbox is in mixed state or not.
 void setCheckMixedOnToggle(boolean checkMixedOnToggle)
          Sets whether partially checked tristate checkbox should be checked or unchecked on toggle.
 void setMixed(boolean mixed)
          Sets whether checkbox is in mixed state or not.
 void setPressed(boolean pressed)
          Sets whether checkbox is pressed or not.
 void setSelected(boolean selected)
          Sets whether checkbox is in checked state or not.
 void setState(CheckState state)
          Sets check state.
 
Methods inherited from class javax.swing.JToggleButton.ToggleButtonModel
isSelected
 
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, setRollover
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIXED

public static final int MIXED
Mixed state bit constant used to store into state mask.

See Also:
Constant Field Values

checkMixedOnToggle

protected boolean checkMixedOnToggle
Whether partially checked tristate checkbox should be checked or unchecked on toggle.

Constructor Detail

TristateCheckBoxModel

public TristateCheckBoxModel()
Constructs new model for the specified WebTristateCheckBox.

Method Detail

isCheckMixedOnToggle

public boolean isCheckMixedOnToggle()
Returns whether partially checked tristate checkbox should be checked or unchecked on toggle

Returns:
true if partially checked tristate checkbox should be checked on toggle, false if it should be unchecked

setCheckMixedOnToggle

public void setCheckMixedOnToggle(boolean checkMixedOnToggle)
Sets whether partially checked tristate checkbox should be checked or unchecked on toggle.

Parameters:
checkMixedOnToggle - whether partially checked tristate checkbox should be checked or unchecked on toggle

setState

public void setState(CheckState state)
Sets check state.

Parameters:
state - new check state

getState

public CheckState getState()

setPressed

public void setPressed(boolean pressed)
Sets whether checkbox is pressed or not.

Specified by:
setPressed in interface javax.swing.ButtonModel
Overrides:
setPressed in class javax.swing.JToggleButton.ToggleButtonModel
Parameters:
pressed - whether checkbox is pressed or not

goToNextState

protected void goToNextState()
Applies next check state to this tristate checkbox according to its settings.


setSelected

public void setSelected(boolean selected)
Sets whether checkbox is in checked state or not.

Specified by:
setSelected in interface javax.swing.ButtonModel
Overrides:
setSelected in class javax.swing.JToggleButton.ToggleButtonModel
Parameters:
selected - whether should set checked state or not

isMixed

public boolean isMixed()
Returns whether checkbox is in mixed state or not.

Returns:
true if checkbox is in mixed state, false otherwise

setMixed

public void setMixed(boolean mixed)
Sets whether checkbox is in mixed state or not.

Parameters:
mixed - whether should set mixed check state or not

getNextState

protected CheckState getNextState(CheckState checkState)
Returns next check state for check invertion action.

Parameters:
checkState - current check state
Returns:
next check state for check invertion action