DefaultCellEditor (Java Platform SE 8 ) (original) (raw)
- 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.
Nested Class Summary
Nested Classes
Modifier and Type Class Description protected class DefaultCellEditor.EditorDelegate The protected EditorDelegate class. Field Summary
Fields
Modifier and Type Field Description protected int clickCountToStart An integer specifying the number of clicks needed to start editing. protected DefaultCellEditor.EditorDelegate delegate The delegate class which handles all methods sent from theCellEditor. protected JComponent editorComponent The Swing component being edited. * ### Fields inherited from class javax.swing.[AbstractCellEditor](../../javax/swing/AbstractCellEditor.html "class in javax.swing") `[changeEvent](../../javax/swing/AbstractCellEditor.html#changeEvent), [listenerList](../../javax/swing/AbstractCellEditor.html#listenerList)`
Constructor Summary
Constructors
Constructor Description DefaultCellEditor(JCheckBox checkBox) Constructs a DefaultCellEditor object that uses a check box. DefaultCellEditor(JComboBox comboBox) Constructs a DefaultCellEditor object that uses a combo box. DefaultCellEditor(JTextField textField) Constructs a DefaultCellEditor that uses a text field. Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type Method Description void cancelCellEditing() Forwards the message from the CellEditor to the delegate. Object getCellEditorValue() Forwards the message from the CellEditor to the delegate. int getClickCountToStart() Returns the number of clicks needed to start editing. Component getComponent() Returns a reference to the editor component. Component getTableCellEditorComponent(JTable table,Object value, boolean isSelected, int row, int column) Implements the TableCellEditor interface. Component getTreeCellEditorComponent(JTree tree,Object value, boolean isSelected, boolean expanded, boolean leaf, int row) Implements the TreeCellEditor interface. boolean isCellEditable(EventObject anEvent) Forwards the message from the CellEditor to the delegate. void setClickCountToStart(int count) Specifies the number of clicks needed to start editing. boolean shouldSelectCell(EventObject anEvent) Forwards the message from the CellEditor to the delegate. boolean stopCellEditing() Forwards the message from the CellEditor to the delegate. * ### Methods inherited from class javax.swing.[AbstractCellEditor](../../javax/swing/AbstractCellEditor.html "class in javax.swing") `[addCellEditorListener](../../javax/swing/AbstractCellEditor.html#addCellEditorListener-javax.swing.event.CellEditorListener-), [fireEditingCanceled](../../javax/swing/AbstractCellEditor.html#fireEditingCanceled--), [fireEditingStopped](../../javax/swing/AbstractCellEditor.html#fireEditingStopped--), [getCellEditorListeners](../../javax/swing/AbstractCellEditor.html#getCellEditorListeners--), [removeCellEditorListener](../../javax/swing/AbstractCellEditor.html#removeCellEditorListener-javax.swing.event.CellEditorListener-)` * ### Methods inherited from class java.lang.[Object](../../java/lang/Object.html "class in java.lang") `[clone](../../java/lang/Object.html#clone--), [equals](../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../java/lang/Object.html#finalize--), [getClass](../../java/lang/Object.html#getClass--), [hashCode](../../java/lang/Object.html#hashCode--), [notify](../../java/lang/Object.html#notify--), [notifyAll](../../java/lang/Object.html#notifyAll--), [toString](../../java/lang/Object.html#toString--), [wait](../../java/lang/Object.html#wait--), [wait](../../java/lang/Object.html#wait-long-), [wait](../../java/lang/Object.html#wait-long-int-)` * ### Methods inherited from interface javax.swing.[CellEditor](../../javax/swing/CellEditor.html "interface in javax.swing") `[addCellEditorListener](../../javax/swing/CellEditor.html#addCellEditorListener-javax.swing.event.CellEditorListener-), [removeCellEditorListener](../../javax/swing/CellEditor.html#removeCellEditorListener-javax.swing.event.CellEditorListener-)`
Field Detail
* #### editorComponent protected [JComponent](../../javax/swing/JComponent.html "class in javax.swing") editorComponent The Swing component being edited. * #### delegate protected [DefaultCellEditor.EditorDelegate](../../javax/swing/DefaultCellEditor.EditorDelegate.html "class in javax.swing") 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 [@ConstructorProperties](../../java/beans/ConstructorProperties.html "annotation in java.beans")([value](../../java/beans/ConstructorProperties.html#value--)="component") public DefaultCellEditor([JTextField](../../javax/swing/JTextField.html "class in javax.swing") textField) Constructs a `DefaultCellEditor` that uses a text field. Parameters: `textField` \- a `JTextField` object * #### DefaultCellEditor public DefaultCellEditor([JCheckBox](../../javax/swing/JCheckBox.html "class in javax.swing") checkBox) Constructs a `DefaultCellEditor` object that uses a check box. Parameters: `checkBox` \- a `JCheckBox` object * #### DefaultCellEditor public DefaultCellEditor([JComboBox](../../javax/swing/JComboBox.html "class in javax.swing") comboBox) Constructs a `DefaultCellEditor` object that uses a combo box. Parameters: `comboBox` \- a `JComboBox` object
Method Detail
* #### getComponent public [Component](../../java/awt/Component.html "class in java.awt") getComponent() Returns a reference to the editor component. Returns: the editor `Component` * #### setClickCountToStart public 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: [getClickCountToStart()](../../javax/swing/DefaultCellEditor.html#getClickCountToStart--) * #### getClickCountToStart public int getClickCountToStart() Returns the number of clicks needed to start editing. Returns: the number of clicks needed to start editing * #### getCellEditorValue public [Object](../../java/lang/Object.html "class in java.lang") getCellEditorValue() Forwards the message from the `CellEditor` to the `delegate`. Specified by: `[getCellEditorValue](../../javax/swing/CellEditor.html#getCellEditorValue--)` in interface `[CellEditor](../../javax/swing/CellEditor.html "interface in javax.swing")` Returns: the value contained in the editor See Also: [DefaultCellEditor.EditorDelegate.getCellEditorValue()](../../javax/swing/DefaultCellEditor.EditorDelegate.html#getCellEditorValue--) * #### isCellEditable public boolean isCellEditable([EventObject](../../java/util/EventObject.html "class in java.util") anEvent) Forwards the message from the `CellEditor` to the `delegate`. Specified by: `[isCellEditable](../../javax/swing/CellEditor.html#isCellEditable-java.util.EventObject-)` in interface `[CellEditor](../../javax/swing/CellEditor.html "interface in javax.swing")` Overrides: `[isCellEditable](../../javax/swing/AbstractCellEditor.html#isCellEditable-java.util.EventObject-)` in class `[AbstractCellEditor](../../javax/swing/AbstractCellEditor.html "class in javax.swing")` Parameters: `anEvent` \- an event object Returns: true See Also: [DefaultCellEditor.EditorDelegate.isCellEditable(EventObject)](../../javax/swing/DefaultCellEditor.EditorDelegate.html#isCellEditable-java.util.EventObject-) * #### shouldSelectCell public boolean shouldSelectCell([EventObject](../../java/util/EventObject.html "class in java.util") anEvent) Forwards the message from the `CellEditor` to the `delegate`. Specified by: `[shouldSelectCell](../../javax/swing/CellEditor.html#shouldSelectCell-java.util.EventObject-)` in interface `[CellEditor](../../javax/swing/CellEditor.html "interface in javax.swing")` Overrides: `[shouldSelectCell](../../javax/swing/AbstractCellEditor.html#shouldSelectCell-java.util.EventObject-)` in class `[AbstractCellEditor](../../javax/swing/AbstractCellEditor.html "class in javax.swing")` Parameters: `anEvent` \- an event object Returns: true See Also: [DefaultCellEditor.EditorDelegate.shouldSelectCell(EventObject)](../../javax/swing/DefaultCellEditor.EditorDelegate.html#shouldSelectCell-java.util.EventObject-) * #### stopCellEditing public boolean stopCellEditing() Forwards the message from the `CellEditor` to the `delegate`. Specified by: `[stopCellEditing](../../javax/swing/CellEditor.html#stopCellEditing--)` in interface `[CellEditor](../../javax/swing/CellEditor.html "interface in javax.swing")` Overrides: `[stopCellEditing](../../javax/swing/AbstractCellEditor.html#stopCellEditing--)` in class `[AbstractCellEditor](../../javax/swing/AbstractCellEditor.html "class in javax.swing")` Returns: true See Also: [DefaultCellEditor.EditorDelegate.stopCellEditing()](../../javax/swing/DefaultCellEditor.EditorDelegate.html#stopCellEditing--) * #### cancelCellEditing public void cancelCellEditing() Forwards the message from the `CellEditor` to the `delegate`. Specified by: `[cancelCellEditing](../../javax/swing/CellEditor.html#cancelCellEditing--)` in interface `[CellEditor](../../javax/swing/CellEditor.html "interface in javax.swing")` Overrides: `[cancelCellEditing](../../javax/swing/AbstractCellEditor.html#cancelCellEditing--)` in class `[AbstractCellEditor](../../javax/swing/AbstractCellEditor.html "class in javax.swing")` See Also: [DefaultCellEditor.EditorDelegate.cancelCellEditing()](../../javax/swing/DefaultCellEditor.EditorDelegate.html#cancelCellEditing--) * #### getTreeCellEditorComponent public [Component](../../java/awt/Component.html "class in java.awt") getTreeCellEditorComponent([JTree](../../javax/swing/JTree.html "class in javax.swing") tree, [Object](../../java/lang/Object.html "class in java.lang") value, boolean isSelected, boolean expanded, boolean leaf, int row) Implements the `TreeCellEditor` interface. Specified by: `[getTreeCellEditorComponent](../../javax/swing/tree/TreeCellEditor.html#getTreeCellEditorComponent-javax.swing.JTree-java.lang.Object-boolean-boolean-boolean-int-)` in interface `[TreeCellEditor](../../javax/swing/tree/TreeCellEditor.html "interface in javax.swing.tree")` 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 * #### getTableCellEditorComponent public [Component](../../java/awt/Component.html "class in java.awt") getTableCellEditorComponent([JTable](../../javax/swing/JTable.html "class in javax.swing") table, [Object](../../java/lang/Object.html "class in java.lang") value, boolean isSelected, int row, int column) Implements the `TableCellEditor` interface. Specified by: `[getTableCellEditorComponent](../../javax/swing/table/TableCellEditor.html#getTableCellEditorComponent-javax.swing.JTable-java.lang.Object-boolean-int-int-)` in interface `[TableCellEditor](../../javax/swing/table/TableCellEditor.html "interface in javax.swing.table")` Parameters: `table` \- the `JTable` that 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. `null` is 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
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.