com.jidesoft.grid
Class TextFieldCellEditor
java.lang.Object
javax.swing.AbstractCellEditor
com.jidesoft.grid.AbstractJideCellEditor
com.jidesoft.grid.ContextSensitiveCellEditor
com.jidesoft.grid.TextFieldCellEditor
- All Implemented Interfaces:
- ConverterContextSupport, EditorContextSupport, EditorStyleSupport, JideCellEditor, ActionListener, Serializable, EventListener, CellEditor, TableCellEditor
- Direct Known Subclasses:
- DimensionCellEditor, NumberCellEditor, PasswordCellEditor, PointCellEditor, RectangleCellEditor, StringCellEditor
public class TextFieldCellEditor
- extends ContextSensitiveCellEditor
- implements TableCellEditor, ActionListener
This class is for any cell editors that need to use JTextField. 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.
- 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 |
_textField
protected JTextField _textField
TextFieldCellEditor
public TextFieldCellEditor(Class<?> clazz)
- Creates a CellEditor using JTextField.
- Parameters:
clazz
- the type of the value
customizeTextField
protected void customizeTextField()
- Customizes the text field.
createTextField
protected JTextField createTextField()
- Creates a text field used by the cell editor. Subclass can override it to return other type of text field. By
default, we will override the processKeyBinding to respect isPassEnterKeyToTable() property.
return new JTextField() {
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean
pressed) {
Container parent = null;
if (e.getSource() != parent && isPassEnterKeyToTable() && e.getKeyCode() ==
KeyEvent.VK_ENTER) {
parent = SwingUtilities.getAncestorOfClass(JideTable.class, this);
}
boolean processed = super.processKeyBinding(ks, e, condition, pressed); // stop cell
editing
if (e.getSource() != parent && parent instanceof JideTable) {
((JideTable) parent).processKeyBinding(ks, e, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
pressed);
}
return processed;
}
};
- 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
getTextField
public JTextField getTextField()
- Gets the text field that is used as the editor.
- Returns:
- the text field.
actionPerformed
public void actionPerformed(ActionEvent e)
- Specified by:
actionPerformed
in interface ActionListener
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.