com.jidesoft.grid
Class SpinnerCellEditor
java.lang.Object
javax.swing.AbstractCellEditor
com.jidesoft.grid.AbstractJideCellEditor
com.jidesoft.grid.ContextSensitiveCellEditor
com.jidesoft.grid.SpinnerCellEditor
- All Implemented Interfaces:
- ConverterContextSupport, EditorContextSupport, EditorStyleSupport, JideCellEditor, Serializable, EventListener, CellEditor, ChangeListener, TableCellEditor
public class SpinnerCellEditor
- extends ContextSensitiveCellEditor
- implements TableCellEditor, ChangeListener
This class is for any cell editors that need to use JSpinner. You need to let it know what's the type of the value so
that it knows to use ConverterContext to converter it to/from string so that the value can be displayed in
JTextField.
We registered in CellEditorManager for type Number.class to use SpinnerCellEditor if the EditorContext is CONTEXT
. You can also register your own type with SpinnerCellEditor. The SpinnerCellEditor also
has a contractor that takes a SpinnerModel as parameter so that you can define your own spinner model. For example,
instead of the step size in spinner model to be 1, you can set a SpinnerNumberModel's stepSize to .01 to make a float
cell editor. See code below for an example.
SpinnerNumberModel model = new SpinnerNumberModel();
model.setValue(new Float(0));
model.setStepSize(0.01f);
SpinnerCellEditor floatCellEditor = new SpinnerCellEditor(model);
- See Also:
- Serialized Form
Methods inherited from class com.jidesoft.grid.ContextSensitiveCellEditor |
getConverter, getConverterContext, getEditorContext, getEditorStyle, getType, 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
_spinner
protected JSpinner _spinner
SpinnerCellEditor
public SpinnerCellEditor()
- Creates a CellEditor using JSpinner.
SpinnerCellEditor
public SpinnerCellEditor(SpinnerModel model)
customizeSpinner
protected void customizeSpinner()
createSpinner
protected JSpinner createSpinner(SpinnerModel model)
- Creates a JSpinner used by the cell editor. Subclass can override it to return other type of JSpinner or further
customize the JSpinner before returning it.
- Parameters:
model
- the spinner model
- Returns:
- a text field.
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
getSpinner
public JSpinner getSpinner()
- Gets the spinner that is used as the cell editor.
- Returns:
- the spinner.
stateChanged
public void stateChanged(ChangeEvent e)
- Specified by:
stateChanged
in interface ChangeListener
isEditorStyleSupported
public boolean isEditorStyleSupported(int editorStyle)
- Description copied from interface:
EditorStyleSupport
- Checks if the editor style is supported by the cell editor.
- Specified by:
isEditorStyleSupported
in interface EditorStyleSupport
- Overrides:
isEditorStyleSupported
in class ContextSensitiveCellEditor
- Parameters:
editorStyle
- the editor style
- Returns:
- true if it is supported. Otherwise false.