net.wotonomy.ui.swing.components
Class KeyableCellEditor
java.lang.Object
net.wotonomy.ui.swing.components.KeyableCellEditor
- All Implemented Interfaces:
- java.awt.event.FocusListener, java.awt.event.KeyListener, java.io.Serializable, java.util.EventListener, javax.swing.CellEditor, javax.swing.table.TableCellEditor
public class KeyableCellEditor
- extends java.lang.Object
- implements javax.swing.table.TableCellEditor, java.awt.event.FocusListener, java.awt.event.KeyListener, java.io.Serializable
A table cell editor customized for keyboard navigation, much like
working with a spreadsheet. The default cell editor unfortunately
does none of these things:
- Selects text on start of editing.
- Up and down keys move edit cell up and down.
- Right and left keys move cell when selection caret is at end of text.
- Escape cancels editing.
- Enter commits edit.
- Edits are properly committed on lost focus.
- Tab and shift-tab work as expected.
- Cell selection moves with the edit cell.
- Version:
- $Revision: 904 $
$Date: 2006-02-18 23:19:05 +0000 (Sat, 18 Feb 2006) $
- Author:
- michael@mpowers.net, $Author: cgruber $
- See Also:
- Serialized Form
Constructor Summary |
KeyableCellEditor()
Default constructor - a standard JTextField will be used for editing. |
KeyableCellEditor(javax.swing.JTextField aTextField)
Constructor specifying a type of JTextField to be used for editing. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KeyableCellEditor
public KeyableCellEditor()
- Default constructor - a standard JTextField will be used for editing.
KeyableCellEditor
public KeyableCellEditor(javax.swing.JTextField aTextField)
- Constructor specifying a type of JTextField to be used for editing.
The JTextField will have its border replaced with a black line border.
- Parameters:
aTextField
- A JTextField or subclass for editing values.
getTableCellEditorComponent
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
int row,
int column)
- Specified by:
getTableCellEditorComponent
in interface javax.swing.table.TableCellEditor
getEditorComponent
protected java.awt.Component getEditorComponent(java.lang.Object value)
getCellEditorValue
public java.lang.Object getCellEditorValue()
- Specified by:
getCellEditorValue
in interface javax.swing.CellEditor
isCellEditable
public boolean isCellEditable(java.util.EventObject anEvent)
- Specified by:
isCellEditable
in interface javax.swing.CellEditor
shouldSelectCell
public boolean shouldSelectCell(java.util.EventObject anEvent)
- Specified by:
shouldSelectCell
in interface javax.swing.CellEditor
stopCellEditing
public boolean stopCellEditing()
- Specified by:
stopCellEditing
in interface javax.swing.CellEditor
cancelCellEditing
public void cancelCellEditing()
- Specified by:
cancelCellEditing
in interface javax.swing.CellEditor
addCellEditorListener
public void addCellEditorListener(javax.swing.event.CellEditorListener l)
- Specified by:
addCellEditorListener
in interface javax.swing.CellEditor
removeCellEditorListener
public void removeCellEditorListener(javax.swing.event.CellEditorListener l)
- Specified by:
removeCellEditorListener
in interface javax.swing.CellEditor
fireEditingCanceled
protected void fireEditingCanceled()
fireEditingStopped
protected void fireEditingStopped()
onEnterKey
protected void onEnterKey()
onEscapeKey
protected void onEscapeKey()
moveEditCell
protected void moveEditCell(int dRow,
int dCol)
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
- Specified by:
keyTyped
in interface java.awt.event.KeyListener
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
- Specified by:
keyPressed
in interface java.awt.event.KeyListener
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Specified by:
keyReleased
in interface java.awt.event.KeyListener
focusGained
public void focusGained(java.awt.event.FocusEvent e)
- Specified by:
focusGained
in interface java.awt.event.FocusListener
focusLost
public void focusLost(java.awt.event.FocusEvent e)
- Specified by:
focusLost
in interface java.awt.event.FocusListener
Copyright © 2006 null. All Rights Reserved.