com.gremwell.history
Class HistoryCellEditor

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by javax.swing.DefaultCellEditor
          extended by 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 Class Summary
 
Nested classes/interfaces inherited from class javax.swing.DefaultCellEditor
javax.swing.DefaultCellEditor.EditorDelegate
 
Field Summary
 
Fields inherited from class javax.swing.DefaultCellEditor
clickCountToStart, delegate, editorComponent
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
HistoryCellEditor(java.lang.String historyKey)
           
 
Method Summary
 java.lang.Object getCellEditorValue()
           
 
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
 

Constructor Detail

HistoryCellEditor

public HistoryCellEditor(java.lang.String historyKey)
Method Detail

getCellEditorValue

public java.lang.Object getCellEditorValue()
Specified by:
getCellEditorValue in interface javax.swing.CellEditor
Overrides:
getCellEditorValue in class javax.swing.DefaultCellEditor