com.gremwell.history
Class HistoryCellEditor
java.lang.Object
javax.swing.AbstractCellEditor
javax.swing.DefaultCellEditor
com.gremwell.history.HistoryCellEditor
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.CellEditor, javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor
public class HistoryCellEditor
- extends javax.swing.DefaultCellEditor
- implements javax.swing.table.TableCellEditor
A TableCellEditor with history and autocompletion. Example:
JTable myTable = new JTable();
...
TableColumn col = myTable.getColumnModel().getColumn(0);
col.setCellEditor(new HistoryCellEditor("StreetAddress"));
col = fieldsTable.getColumnModel().getColumn(1);
col.setCellEditor(new HistoryCellEditor("PostalCode"));
myTable.setSurrendersFocusOnKeystroke(true); // This is important
// When this property is not set, when you start typing in a cell
// the autocompleted part of the text is selected, but the selection
// is not highlighted, which looks weird
This code sets cell editors with autocomplete for two tavble columns. Each column
uses different input history.
- See Also:
- Serialized Form
| Nested classes/interfaces inherited from class javax.swing.DefaultCellEditor |
javax.swing.DefaultCellEditor.EditorDelegate |
| Fields inherited from class javax.swing.DefaultCellEditor |
clickCountToStart, delegate, editorComponent |
| Fields inherited from class javax.swing.AbstractCellEditor |
changeEvent, listenerList |
| Methods inherited from class javax.swing.DefaultCellEditor |
cancelCellEditing, getClickCountToStart, getComponent, getTableCellEditorComponent, getTreeCellEditorComponent, isCellEditable, setClickCountToStart, shouldSelectCell, stopCellEditing |
| Methods inherited from class javax.swing.AbstractCellEditor |
addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.swing.table.TableCellEditor |
getTableCellEditorComponent |
| Methods inherited from interface javax.swing.CellEditor |
addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing |
HistoryCellEditor
public HistoryCellEditor(java.lang.String historyKey)
getCellEditorValue
public java.lang.Object getCellEditorValue()
- Specified by:
getCellEditorValue in interface javax.swing.CellEditor- Overrides:
getCellEditorValue in class javax.swing.DefaultCellEditor