JIDE 3.5.15

com.jidesoft.grid
Class BooleanCheckBoxCellEditor

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.BooleanCheckBoxCellEditor
All Implemented Interfaces:
ConverterContextSupport, EditorContextSupport, EditorStyleSupport, JideCellEditor, ItemListener, Serializable, EventListener, CellEditor, TableCellEditor

public class BooleanCheckBoxCellEditor
extends ContextSensitiveCellEditor
implements TableCellEditor, ItemListener

CellEditor for Boolean. There are two ways to display a boolean in JTable - using JCheckBox or JComboBox. This class is the implementation using JCheckBox. By default, it will use BooleanCellEditor which uses JComboBox. If you want to use JCheckBox, you just need to specify the EditorContext as CONTEXT.

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 BooleanCheckBoxCellEditor() {
             protected void configureCheckBox() {
                 super.configureCheckBox();
                 _checkBox.setHorizontalAlignment(SwingConstants.LEFT);
             }
         };
     }
 };
 CellEditorManager.registerEditor(Boolean.class, editorFactory, BooleanCheckBoxCellEditor.CONTEXT);
 CellEditorManager.registerEditor(boolean.class, editorFactory, BooleanCheckBoxCellEditor.CONTEXT);
 

See Also:
Serialized Form

Field Summary
protected  JCheckBox _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
BooleanCheckBoxCellEditor()
          Creates a ListComboBoxCellEditor that contains the elements in the specified array.
 
Method Summary
protected  void configureCheckBox()
          Configures the check box.
protected  JCheckBox createCheckBox()
          Creates the check box.
protected  void customizeCheckBox()
           
 Object getCellEditorValue()
           
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
           
 void itemStateChanged(ItemEvent e)
           
 void setCellEditorValue(Object value)
           
 boolean stopCellEditing()
           
 
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
 
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
 

Field Detail

CONTEXT

public static EditorContext CONTEXT

_checkBox

protected JCheckBox _checkBox
Constructor Detail

BooleanCheckBoxCellEditor

public BooleanCheckBoxCellEditor()
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 JCheckBox 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()

stopCellEditing

public boolean stopCellEditing()
Specified by:
stopCellEditing in interface CellEditor
Overrides:
stopCellEditing in class AbstractCellEditor

itemStateChanged

public void itemStateChanged(ItemEvent e)
Specified by:
itemStateChanged in interface ItemListener

JIDE 3.5.15