DefaultCellEditor (Java SE 15 & JDK 15) (original) (raw)
All Implemented Interfaces:
[Serializable](../../../java.base/java/io/Serializable.html "interface in java.io")
, [CellEditor](CellEditor.html "interface in javax.swing")
, [TableCellEditor](table/TableCellEditor.html "interface in javax.swing.table")
, [TreeCellEditor](tree/TreeCellEditor.html "interface in javax.swing.tree")
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 Summary
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. |
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
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 declared in class java.lang.Object
[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)
Field Details
editorComponent
The Swing component being edited.
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 ifclickCountToStart
is defined as zero, it will not initiate until a click occurs.Constructor Details
DefaultCellEditor
Constructs a
DefaultCellEditor
that uses a text field.
Parameters:
textField
- aJTextField
objectDefaultCellEditor
public DefaultCellEditor(JCheckBox checkBox)
Constructs aDefaultCellEditor
object that uses a check box.
Parameters:
checkBox
- aJCheckBox
objectDefaultCellEditor
public DefaultCellEditor(JComboBox<?> comboBox)
Constructs aDefaultCellEditor
object that uses a combo box.
Parameters:
comboBox
- aJComboBox
objectMethod Details
getComponent
Returns a reference to the editor component.
Returns:
the editorComponent
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()getClickCountToStart
public int getClickCountToStart()
Returns the number of clicks needed to start editing.
Returns:
the number of clicks needed to start editinggetCellEditorValue
public Object getCellEditorValue()
Forwards the message from theCellEditor
to thedelegate
.
Specified by:
[getCellEditorValue](CellEditor.html#getCellEditorValue%28%29)
in interface[CellEditor](CellEditor.html "interface in javax.swing")
Returns:
the value contained in the editor
See Also:
DefaultCellEditor.EditorDelegate.getCellEditorValue()isCellEditable
public boolean isCellEditable(EventObject anEvent)
Forwards the message from theCellEditor
to thedelegate
.
Specified by:
[isCellEditable](CellEditor.html#isCellEditable%28java.util.EventObject%29)
in interface[CellEditor](CellEditor.html "interface in javax.swing")
Overrides:
[isCellEditable](AbstractCellEditor.html#isCellEditable%28java.util.EventObject%29)
in class[AbstractCellEditor](AbstractCellEditor.html "class in javax.swing")
Parameters:
anEvent
- an event object
Returns:
true
See Also:
DefaultCellEditor.EditorDelegate.isCellEditable(EventObject)shouldSelectCell
public boolean shouldSelectCell(EventObject anEvent)
Forwards the message from theCellEditor
to thedelegate
.
Specified by:
[shouldSelectCell](CellEditor.html#shouldSelectCell%28java.util.EventObject%29)
in interface[CellEditor](CellEditor.html "interface in javax.swing")
Overrides:
[shouldSelectCell](AbstractCellEditor.html#shouldSelectCell%28java.util.EventObject%29)
in class[AbstractCellEditor](AbstractCellEditor.html "class in javax.swing")
Parameters:
anEvent
- an event object
Returns:
true
See Also:
DefaultCellEditor.EditorDelegate.shouldSelectCell(EventObject)stopCellEditing
public boolean stopCellEditing()
Forwards the message from theCellEditor
to thedelegate
.
Specified by:
[stopCellEditing](CellEditor.html#stopCellEditing%28%29)
in interface[CellEditor](CellEditor.html "interface in javax.swing")
Overrides:
[stopCellEditing](AbstractCellEditor.html#stopCellEditing%28%29)
in class[AbstractCellEditor](AbstractCellEditor.html "class in javax.swing")
Returns:
true
See Also:
DefaultCellEditor.EditorDelegate.stopCellEditing()cancelCellEditing
public void cancelCellEditing()
Forwards the message from theCellEditor
to thedelegate
.
Specified by:
[cancelCellEditing](CellEditor.html#cancelCellEditing%28%29)
in interface[CellEditor](CellEditor.html "interface in javax.swing")
Overrides:
[cancelCellEditing](AbstractCellEditor.html#cancelCellEditing%28%29)
in class[AbstractCellEditor](AbstractCellEditor.html "class in javax.swing")
See Also:
DefaultCellEditor.EditorDelegate.cancelCellEditing()getTreeCellEditorComponent
public Component getTreeCellEditorComponent(JTree tree,Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
Implements theTreeCellEditor
interface.
Specified by:
[getTreeCellEditorComponent](tree/TreeCellEditor.html#getTreeCellEditorComponent%28javax.swing.JTree,java.lang.Object,boolean,boolean,boolean,int%29)
in interface[TreeCellEditor](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 editinggetTableCellEditorComponent
public Component getTableCellEditorComponent(JTable table,Object value, boolean isSelected, int row, int column)
Implements theTableCellEditor
interface.
Specified by:
[getTableCellEditorComponent](table/TableCellEditor.html#getTableCellEditorComponent%28javax.swing.JTable,java.lang.Object,boolean,int,int%29)
in interface[TableCellEditor](table/TableCellEditor.html "interface in javax.swing.table")
Parameters:
table
- theJTable
that is asking the editor to edit; can benull
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