Class DefaultCellEditor
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 Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThe protectedEditorDelegateclass. -
Field Summary
FieldsModifier 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 AbstractCellEditor
changeEvent, listenerListModifier and TypeFieldDescriptionprotected ChangeEventThe change event.protected EventListenerListThe list of listeners. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCellEditor(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 Summary
Modifier 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 AbstractCellEditor
addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListenerModifier and TypeMethodDescriptionvoidAdds aCellEditorListenerto the listener list.protected voidNotifies all listeners that have registered interest for notification on this event type.protected voidNotifies all listeners that have registered interest for notification on this event type.Returns an array of all theCellEditorListeners added to this AbstractCellEditor with addCellEditorListener().voidRemoves aCellEditorListenerfrom the listener list.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Field Details
-
editorComponent
The Swing component being edited. -
delegate
The delegate class which handles all methods sent from theCellEditor. -
clickCountToStart
protected 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
-
DefaultCellEditor
Constructs aDefaultCellEditorthat uses a text field.- Parameters:
textField- aJTextFieldobject
-
DefaultCellEditor
Constructs aDefaultCellEditorobject that uses a check box.- Parameters:
checkBox- aJCheckBoxobject
-
DefaultCellEditor
Constructs aDefaultCellEditorobject that uses a combo box.- Parameters:
comboBox- aJComboBoxobject
-
-
Method Details
-
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
public int getClickCountToStart()Returns the number of clicks needed to start editing.- Returns:
- the number of clicks needed to start editing
-
getCellEditorValue
Forwards the message from theCellEditorto thedelegate.- Specified by:
getCellEditorValuein interfaceCellEditor- Returns:
- the value contained in the editor
- See Also:
-
isCellEditable
Forwards the message from theCellEditorto thedelegate.- Specified by:
isCellEditablein interfaceCellEditor- Overrides:
isCellEditablein classAbstractCellEditor- Parameters:
anEvent- an event object- Returns:
- true
- See Also:
-
shouldSelectCell
Forwards the message from theCellEditorto thedelegate.- Specified by:
shouldSelectCellin interfaceCellEditor- Overrides:
shouldSelectCellin classAbstractCellEditor- Parameters:
anEvent- an event object- Returns:
- true
- See Also:
-
stopCellEditing
public boolean stopCellEditing()Forwards the message from theCellEditorto thedelegate.- Specified by:
stopCellEditingin interfaceCellEditor- Overrides:
stopCellEditingin classAbstractCellEditor- Returns:
- true
- See Also:
-
cancelCellEditing
public void cancelCellEditing()Forwards the message from theCellEditorto thedelegate.- Specified by:
cancelCellEditingin interfaceCellEditor- Overrides:
cancelCellEditingin classAbstractCellEditor- See Also:
-
getTreeCellEditorComponent
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) Implements theTreeCellEditorinterface.- Specified by:
getTreeCellEditorComponentin interfaceTreeCellEditor- Parameters:
tree- the JTree that is asking the editor to edit; this parameter can be nullvalue- the value of the cell to be editedisSelected- true if the cell is to be rendered with selection highlightingexpanded- true if the node is expandedleaf- true if the node is a leaf noderow- the row index of the node being edited- Returns:
- the component for editing
-
getTableCellEditorComponent
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) Implements theTableCellEditorinterface.- Specified by:
getTableCellEditorComponentin interfaceTableCellEditor- Parameters:
table- theJTablethat is asking the editor to edit; can benullvalue- 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 valueisSelected- true if the cell is to be rendered with highlightingrow- the row of the cell being editedcolumn- the column of the cell being edited- Returns:
- the component for editing
-