java.lang.Object
javax.swing.AbstractCellEditor
javax.swing.DefaultCellEditor
- All Implemented Interfaces:
- Serializable,- CellEditor,- TableCellEditor,- TreeCellEditor
public class DefaultCellEditor
extends AbstractCellEditor
implements TableCellEditor, TreeCellEditor
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 JavaBeans
 has been added to the java.beans package.
 Please see XMLEncoder.
- Since:
- 1.2
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classThe protectedEditorDelegateclass.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intAn integer specifying the number of clicks needed to start editing.protected DefaultCellEditor.EditorDelegateThe delegate class which handles all methods sent from theCellEditor.protected JComponentThe Swing component being edited.Fields declared in class javax.swing.AbstractCellEditorchangeEvent, listenerList
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultCellEditor(JCheckBox checkBox) Constructs aDefaultCellEditorobject that uses a check box.DefaultCellEditor(JComboBox<?> comboBox) Constructs aDefaultCellEditorobject that uses a combo box.DefaultCellEditor(JTextField textField) Constructs aDefaultCellEditorthat uses a text field.
- 
Method SummaryModifier and TypeMethodDescriptionvoidForwards the message from theCellEditorto thedelegate.Forwards the message from theCellEditorto thedelegate.intReturns the number of clicks needed to start editing.Returns a reference to the editor component.getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) Implements theTableCellEditorinterface.getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) Implements theTreeCellEditorinterface.booleanisCellEditable(EventObject anEvent) Forwards the message from theCellEditorto thedelegate.voidsetClickCountToStart(int count) Specifies the number of clicks needed to start editing.booleanshouldSelectCell(EventObject anEvent) Forwards the message from theCellEditorto thedelegate.booleanForwards the message from theCellEditorto thedelegate.Methods declared in class javax.swing.AbstractCellEditoraddCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListenerMethods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface javax.swing.CellEditoraddCellEditorListener, removeCellEditorListener
- 
Field Details- 
editorComponentThe Swing component being edited.
- 
delegateThe delegate class which handles all methods sent from theCellEditor.
- 
clickCountToStartprotected int clickCountToStartAn integer specifying the number of clicks needed to start editing. Even ifclickCountToStartis defined as zero, it will not initiate until a click occurs.
 
- 
- 
Constructor Details- 
DefaultCellEditorConstructs aDefaultCellEditorthat uses a text field.- Parameters:
- textField- a- JTextFieldobject
 
- 
DefaultCellEditorConstructs aDefaultCellEditorobject that uses a check box.- Parameters:
- checkBox- a- JCheckBoxobject
 
- 
DefaultCellEditorConstructs aDefaultCellEditorobject that uses a combo box.- Parameters:
- comboBox- a- JComboBoxobject
 
 
- 
- 
Method Details- 
getComponentReturns a reference to the editor component.- Returns:
- the editor Component
 
- 
setClickCountToStartpublic void setClickCountToStart(int count) Specifies the number of clicks needed to start editing.- Parameters:
- count- an int specifying the number of clicks needed to start editing
- See Also:
 
- 
getClickCountToStartpublic int getClickCountToStart()Returns the number of clicks needed to start editing.- Returns:
- the number of clicks needed to start editing
 
- 
getCellEditorValueForwards the message from theCellEditorto thedelegate.- Specified by:
- getCellEditorValuein interface- CellEditor
- Returns:
- the value contained in the editor
- See Also:
 
- 
isCellEditableForwards the message from theCellEditorto thedelegate.- Specified by:
- isCellEditablein interface- CellEditor
- Overrides:
- isCellEditablein class- AbstractCellEditor
- Parameters:
- anEvent- an event object
- Returns:
- true
- See Also:
 
- 
shouldSelectCellForwards the message from theCellEditorto thedelegate.- Specified by:
- shouldSelectCellin interface- CellEditor
- Overrides:
- shouldSelectCellin class- AbstractCellEditor
- Parameters:
- anEvent- an event object
- Returns:
- true
- See Also:
 
- 
stopCellEditingpublic boolean stopCellEditing()Forwards the message from theCellEditorto thedelegate.- Specified by:
- stopCellEditingin interface- CellEditor
- Overrides:
- stopCellEditingin class- AbstractCellEditor
- Returns:
- true
- See Also:
 
- 
cancelCellEditingpublic void cancelCellEditing()Forwards the message from theCellEditorto thedelegate.- Specified by:
- cancelCellEditingin interface- CellEditor
- Overrides:
- cancelCellEditingin class- AbstractCellEditor
- See Also:
 
- 
getTreeCellEditorComponentpublic Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) Implements theTreeCellEditorinterface.- Specified by:
- getTreeCellEditorComponentin interface- TreeCellEditor
- Parameters:
- tree- the JTree that is asking the editor to edit; this parameter can be null
- value- the value of the cell to be edited
- isSelected- true if the cell is to be rendered with selection highlighting
- expanded- true if the node is expanded
- leaf- true if the node is a leaf node
- row- the row index of the node being edited
- Returns:
- the component for editing
 
- 
getTableCellEditorComponentpublic Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) Implements theTableCellEditorinterface.- Specified by:
- getTableCellEditorComponentin interface- TableCellEditor
- Parameters:
- table- the- JTablethat is asking the editor to edit; can be- null
- value- the value of the cell to be edited; it is up to the specific editor to interpret and draw the value. For example, if value is the string "true", it could be rendered as a string or it could be rendered as a check box that is checked.- nullis a valid value
- isSelected- true if the cell is to be rendered with highlighting
- row- the row of the cell being edited
- column- the column of the cell being edited
- Returns:
- the component for editing
 
 
-