javax.swing
Class DefaultCellEditor

java.lang.Object
  |
  +--javax.swing.AbstractCellEditor
        |
        +--javax.swing.DefaultCellEditor
All Implemented Interfaces:
CellEditor, Serializable, javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor
Direct Known Subclasses:
javax.swing.JTable.BooleanEditor, javax.swing.JTable.GenericEditor

public class DefaultCellEditor
extends AbstractCellEditor
implements javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor

Safe: The default editor for table and tree cells.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder.

Version:
1.47 02/11/02
Author:
Alan Chung, Philip Milne
See Also:
Serialized Form

Field Summary
protected  int clickCountToStart
          An integer specifying the number of clicks needed to start editing.
protected  javax.swing.DefaultCellEditor.EditorDelegate delegate
          The delegate class which handles all methods sent from the CellEditor.
protected  JComponent editorComponent
          The Swing component being edited.
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
DefaultCellEditor(JCheckBox checkBox)
          Enabled: Constructs a DefaultCellEditor object that uses a check box.
DefaultCellEditor(JComboBox comboBox)
          Enabled: Constructs a DefaultCellEditor object that uses a combo box.
DefaultCellEditor(JTextField textField)
          Enabled: Constructs a DefaultCellEditor that uses a text field.
 
Method Summary
 void cancelCellEditing()
          Enabled: Forwards the message from the CellEditor to the delegate.
 Object getCellEditorValue()
          Enabled: Forwards the message from the CellEditor to the delegate.
 int getClickCountToStart()
          Enabled: Returns the number of clicks needed to start editing.
 Component getComponent()
          Enabled: Returns a reference to the editor component.
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
          Enabled: Implements the TableCellEditor interface.
 Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
          Enabled: Implements the TreeCellEditor interface.
 boolean isCellEditable(EventObject anEvent)
          Enabled: Forwards the message from the CellEditor to the delegate.
 void setClickCountToStart(int count)
          Enabled: Specifies the number of clicks needed to start editing.
 boolean shouldSelectCell(EventObject anEvent)
          Enabled: Forwards the message from the CellEditor to the delegate.
 boolean stopCellEditing()
          Enabled: Forwards the message from the CellEditor to the delegate.
 
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

editorComponent

protected JComponent editorComponent
The Swing component being edited.


delegate

protected javax.swing.DefaultCellEditor.EditorDelegate delegate
The delegate class which handles all methods sent from the CellEditor.


clickCountToStart

protected int clickCountToStart
An integer specifying the number of clicks needed to start editing. Even if clickCountToStart is defined as zero, it will not initiate until a click occurs.

Constructor Detail

DefaultCellEditor

public DefaultCellEditor(JTextField textField)
Enabled: Constructs a DefaultCellEditor that uses a text field.


DefaultCellEditor

public DefaultCellEditor(JCheckBox checkBox)
Enabled: Constructs a DefaultCellEditor object that uses a check box.


DefaultCellEditor

public DefaultCellEditor(JComboBox comboBox)
Enabled: Constructs a DefaultCellEditor object that uses a combo box.

Method Detail

getComponent

public Component getComponent()
Enabled: Returns a reference to the editor component.

Returns:
the editor Component

setClickCountToStart

public void setClickCountToStart(int count)
Enabled: Specifies the number of clicks needed to start editing.

Parameters:
count - an int specifying the number of clicks needed to start editing
See Also:
getClickCountToStart()

getClickCountToStart

public int getClickCountToStart()
Enabled: Returns the number of clicks needed to start editing.


getCellEditorValue

public Object getCellEditorValue()
Enabled: Forwards the message from the CellEditor to the delegate.

Specified by:
getCellEditorValue in interface CellEditor
Returns:
the value contained in the editor
See Also:
EditorDelegate.getCellEditorValue()

isCellEditable

public boolean isCellEditable(EventObject anEvent)
Enabled: Forwards the message from the CellEditor to the delegate.

Specified by:
isCellEditable in interface CellEditor
Overrides:
isCellEditable in class AbstractCellEditor
Parameters:
anEvent - the event the editor should use to consider whether to begin editing or not
Returns:
true if editing can be started
See Also:
EditorDelegate.isCellEditable(EventObject)

shouldSelectCell

public boolean shouldSelectCell(EventObject anEvent)
Enabled: Forwards the message from the CellEditor to the delegate.

Specified by:
shouldSelectCell in interface CellEditor
Overrides:
shouldSelectCell in class AbstractCellEditor
Parameters:
anEvent - the event the editor should use to start editing
Returns:
true if the editor would like the editing cell to be selected; otherwise returns false
See Also:
EditorDelegate.shouldSelectCell(EventObject)

stopCellEditing

public boolean stopCellEditing()
Enabled: Forwards the message from the CellEditor to the delegate.

Specified by:
stopCellEditing in interface CellEditor
Overrides:
stopCellEditing in class AbstractCellEditor
Returns:
true if editing was stopped; false otherwise
See Also:
EditorDelegate.stopCellEditing()

cancelCellEditing

public void cancelCellEditing()
Enabled: Forwards the message from the CellEditor to the delegate.

Specified by:
cancelCellEditing in interface CellEditor
Overrides:
cancelCellEditing in class AbstractCellEditor
See Also:
EditorDelegate.cancelCellEditing()

getTreeCellEditorComponent

public Component getTreeCellEditorComponent(JTree tree,
                                            Object value,
                                            boolean isSelected,
                                            boolean expanded,
                                            boolean leaf,
                                            int row)
Enabled: Implements the TreeCellEditor interface.


getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Enabled: Implements the TableCellEditor interface.



comments?