org.tbee.swing.table
Class GenericEditor

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by javax.swing.DefaultCellEditor
          extended by org.tbee.swing.table.DefaultCellEditor
              extended by org.tbee.swing.table.GenericEditor
All Implemented Interfaces:
Serializable, CellEditor, TableCellEditor, TreeCellEditor

public class GenericEditor
extends DefaultCellEditor

Extracted from javax.swing.JTable, but removed the border logic This class uses toString and the string constructor of the column class (as returned by the table model) to render and parse the value. This would create a number editor: static class NumberEditor extends GenericEditor { public NumberEditor() { ((JTextField)getComponent()).setHorizontalAlignment(JTextField.RIGHT); } } And this a boolean editor: static class BooleanEditor extends DefaultCellEditor { public BooleanEditor() { super(new JCheckBox()); JCheckBox checkBox = (JCheckBox)getComponent(); checkBox.setHorizontalAlignment(JCheckBox.CENTER); } }

Author:
user
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.DefaultCellEditor
DefaultCellEditor.EditorDelegate
 
Field Summary
protected  Class[] iArgTypes
           
protected  Constructor iConstructor
           
protected  Object iValue
           
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Fields inherited from class javax.swing.DefaultCellEditor
clickCountToStart, delegate, editorComponent
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
GenericEditor()
           
 
Method Summary
 Object getCellEditorValue()
           
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
          Convert object to string and render
 boolean stopCellEditing()
          Convert string to object using string constructor and return value
 
Methods inherited from class org.tbee.swing.table.DefaultCellEditor
requestFocus, useAsRenderer
 
Methods inherited from class javax.swing.DefaultCellEditor
cancelCellEditing, getClickCountToStart, getComponent, getTreeCellEditorComponent, isCellEditable, setClickCountToStart, shouldSelectCell
 
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.CellEditor
addCellEditorListener, removeCellEditorListener
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

iArgTypes

protected Class[] iArgTypes

iConstructor

protected Constructor iConstructor

iValue

protected Object iValue
Constructor Detail

GenericEditor

public GenericEditor()
Method Detail

stopCellEditing

public boolean stopCellEditing()
Convert string to object using string constructor and return value

Specified by:
stopCellEditing in interface CellEditor
Overrides:
stopCellEditing in class DefaultCellEditor

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Convert object to string and render

Specified by:
getTableCellEditorComponent in interface TableCellEditor
Overrides:
getTableCellEditorComponent in class DefaultCellEditor

getCellEditorValue

public Object getCellEditorValue()
Specified by:
getCellEditorValue in interface CellEditor
Overrides:
getCellEditorValue in class DefaultCellEditor


Copyright © 2012 KnowledgePlaza. All Rights Reserved.