JIDE 3.5.15

com.jidesoft.grid
Class TristateCheckBoxCellEditor

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by com.jidesoft.grid.AbstractJideCellEditor
          extended by com.jidesoft.grid.ContextSensitiveCellEditor
              extended by com.jidesoft.grid.TristateCheckBoxCellEditor
All Implemented Interfaces:
ConverterContextSupport, EditorContextSupport, EditorStyleSupport, JideCellEditor, ActionListener, Serializable, EventListener, CellEditor, TableCellEditor

public class TristateCheckBoxCellEditor
extends ContextSensitiveCellEditor
implements TableCellEditor, ActionListener

CellEditor based on TristateCheckBox. It uses int or Integer as the data type. 0 means not selected, 1 means selected and 2 means partially selected. If you want to use some other data types or change the meaning of integers, you need to override both setCellEditorValue(Object) and getCellEditorValue().

The check box is center aligned by default. If you want to make it left aligned, you can use the code below to change it.

 CellEditorManager.initDefaultEditor();
 CellEditorFactory editorFactory = new CellEditorFactory() {
     public CellEditor create() {
         return new TristateCheckBoxCellEditor() {
             protected void configureCheckBox() {
                 super.configureCheckBox();
                 _checkBox.setHorizontalAlignment(SwingConstants.LEFT);
             }
         };
     }
 };
 CellEditorManager.registerEditor(int.class, editorFactory, TristateCheckBoxCellEditor.CONTEXT);
 CellEditorManager.registerEditor(Integer.class, editorFactory, TristateCheckBoxCellEditor.CONTEXT);
 

See Also:
Serialized Form

Field Summary
protected  TristateCheckBox _checkBox
           
static EditorContext CONTEXT
           
 
Fields inherited from class com.jidesoft.grid.ContextSensitiveCellEditor
DEFAULT_CELL_EDITOR_BORDER
 
Fields inherited from class com.jidesoft.grid.AbstractJideCellEditor
_clickCountToStart
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
TristateCheckBoxCellEditor()
          Creates a ListComboBoxCellEditor that contains the elements in the specified array.
 
Method Summary
 void actionPerformed(ActionEvent evt)
           
protected  void configureCheckBox()
          Configures the check box.
protected  TristateCheckBox createCheckBox()
          Creates the check box.
protected  void customizeCheckBox()
           
 Object getCellEditorValue()
           
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
           
 void setCellEditorValue(Object value)
           
 
Methods inherited from class com.jidesoft.grid.ContextSensitiveCellEditor
getConverter, getConverterContext, getEditorContext, getEditorStyle, getType, isEditorStyleSupported, isUseConverterContext, setConverter, setConverterContext, setEditorContext, setEditorStyle, setType, setUseConverterContext
 
Methods inherited from class com.jidesoft.grid.AbstractJideCellEditor
addValidationListener, getClickCountToStart, getDefaultErrorBehavior, getValidationListeners, isAutoStopCellEditing, isCellEditable, isPassEnterKeyToTable, removeValidationListener, setAutoStopCellEditing, setClickCountToStart, setDefaultErrorBehavior, setPassEnterKeyToTable, validate
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener, shouldSelectCell, stopCellEditing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
 

Field Detail

CONTEXT

public static EditorContext CONTEXT

_checkBox

protected TristateCheckBox _checkBox
Constructor Detail

TristateCheckBoxCellEditor

public TristateCheckBoxCellEditor()
Creates a ListComboBoxCellEditor that contains the elements in the specified array. By default the first item in the array (and therefore the data model) becomes selected.

Method Detail

createCheckBox

protected TristateCheckBox createCheckBox()
Creates the check box.

Returns:
the check box.

configureCheckBox

protected void configureCheckBox()
Configures the check box. The default implementation will set horizontal alignment to center and set border to empty border.


getCellEditorValue

public Object getCellEditorValue()
Specified by:
getCellEditorValue in interface CellEditor

setCellEditorValue

public void setCellEditorValue(Object value)

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Specified by:
getTableCellEditorComponent in interface TableCellEditor

customizeCheckBox

protected void customizeCheckBox()

actionPerformed

public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener

JIDE 3.5.15