dsto.dfc.swing.controls
Class JTextFieldEditorAdapter

java.lang.Object
  extended by dsto.dfc.swing.controls.JTextFieldEditorAdapter
All Implemented Interfaces:
ActionListener, FocusListener, EventListener, CellEditor, TableCellEditor, TreeCellEditor

public class JTextFieldEditorAdapter
extends Object
implements TableCellEditor, TreeCellEditor, ActionListener, FocusListener

Adapts a JTextField to the TableCellEditor and TreeCellEditor interfaces. Supports use of a ValueConverter and the Objects.convertValue () method to provide auto data conversion to/from text and the form used by the model.

Version:
$Revision$

Constructor Summary
JTextFieldEditorAdapter(JTextField textField)
          Create an adapter with no data conversion (ie text is copied directly to model).
JTextFieldEditorAdapter(JTextField textField, Class valueClass)
          Create an adapter that converts data from text field to values of a given type.
JTextFieldEditorAdapter(JTextField textField, Class valueClass, ValueConverter converter)
          Create an adapter that converts data from text field to values of a given type.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addCellEditorListener(CellEditorListener l)
           
 void cancelCellEditing()
           
protected  void fireEditingCanceled(ChangeEvent e)
           
protected  void fireEditingStopped(ChangeEvent e)
           
 void focusGained(FocusEvent e)
           
 void focusLost(FocusEvent e)
           
 Object getCellEditorValue()
           
 int getClickCountToEdit()
           
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
           
 Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
           
 Class getValueClass()
           
 boolean isCellEditable(EventObject e)
           
 void removeCellEditorListener(CellEditorListener l)
           
 void setClickCountToEdit(int newValue)
           
 void setValueClass(Class newValueClass)
           
 boolean shouldSelectCell(EventObject e)
           
 Component startEditor(Object value)
           
 boolean stopCellEditing()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTextFieldEditorAdapter

public JTextFieldEditorAdapter(JTextField textField)
Create an adapter with no data conversion (ie text is copied directly to model).


JTextFieldEditorAdapter

public JTextFieldEditorAdapter(JTextField textField,
                               Class valueClass)
Create an adapter that converts data from text field to values of a given type.

Parameters:
textField - The text field to use for editing.
valueClass - The class of value to return to the model.

JTextFieldEditorAdapter

public JTextFieldEditorAdapter(JTextField textField,
                               Class valueClass,
                               ValueConverter converter)
Create an adapter that converts data from text field to values of a given type.

Parameters:
textField - The text field to use for editing.
valueClass - The class of value to return to the model.
converter - The converter instance to use for conversion to/from text and the model form.
Method Detail

getValueClass

public Class getValueClass()

setValueClass

public void setValueClass(Class newValueClass)

getClickCountToEdit

public int getClickCountToEdit()

setClickCountToEdit

public void setClickCountToEdit(int newValue)

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

focusGained

public void focusGained(FocusEvent e)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent e)
Specified by:
focusLost in interface FocusListener

startEditor

public Component startEditor(Object value)

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Specified by:
getTableCellEditorComponent in interface TableCellEditor

getTreeCellEditorComponent

public Component getTreeCellEditorComponent(JTree tree,
                                            Object value,
                                            boolean isSelected,
                                            boolean expanded,
                                            boolean leaf,
                                            int row)
Specified by:
getTreeCellEditorComponent in interface TreeCellEditor

getCellEditorValue

public Object getCellEditorValue()
Specified by:
getCellEditorValue in interface CellEditor

isCellEditable

public boolean isCellEditable(EventObject e)
Specified by:
isCellEditable in interface CellEditor

shouldSelectCell

public boolean shouldSelectCell(EventObject e)
Specified by:
shouldSelectCell in interface CellEditor

stopCellEditing

public boolean stopCellEditing()
Specified by:
stopCellEditing in interface CellEditor

cancelCellEditing

public void cancelCellEditing()
Specified by:
cancelCellEditing in interface CellEditor

removeCellEditorListener

public void removeCellEditorListener(CellEditorListener l)
Specified by:
removeCellEditorListener in interface CellEditor

addCellEditorListener

public void addCellEditorListener(CellEditorListener l)
Specified by:
addCellEditorListener in interface CellEditor

fireEditingCanceled

protected void fireEditingCanceled(ChangeEvent e)

fireEditingStopped

protected void fireEditingStopped(ChangeEvent e)


Copyright © 2008 Commonwealth of Australia