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()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
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
-