com.jidesoft.grid
Class BooleanCheckBoxCellEditor
java.lang.Object
javax.swing.AbstractCellEditor
com.jidesoft.grid.AbstractJideCellEditor
com.jidesoft.grid.ContextSensitiveCellEditor
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
Constructor Summary |
BooleanCheckBoxCellEditor()
Creates a ListComboBoxCellEditor that contains the elements in the specified array. |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CONTEXT
public static EditorContext CONTEXT
_checkBox
protected JCheckBox _checkBox
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.
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