- 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 JavaBeansTM has been added to the
java.beans
package. Please seeXMLEncoder
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected class
DefaultCellEditor.EditorDelegate
The protectedEditorDelegate
class.
-
Field Summary
Fields Modifier and Type Field and 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
changeEvent, listenerList
-
-
Constructor Summary
Constructors Constructor and Description DefaultCellEditor(JCheckBox checkBox)
Constructs aDefaultCellEditor
object that uses a check box.DefaultCellEditor(JComboBox comboBox)
Constructs aDefaultCellEditor
object that uses a combo box.DefaultCellEditor(JTextField textField)
Constructs aDefaultCellEditor
that uses a text field.
-
Method Summary
Methods Modifier and Type Method and Description void
cancelCellEditing()
Forwards the message from theCellEditor
to thedelegate
.Object
getCellEditorValue()
Forwards the message from theCellEditor
to thedelegate
.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 theTableCellEditor
interface.Component
getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
Implements theTreeCellEditor
interface.boolean
isCellEditable(EventObject anEvent)
Forwards the message from theCellEditor
to thedelegate
.void
setClickCountToStart(int count)
Specifies the number of clicks needed to start editing.boolean
shouldSelectCell(EventObject anEvent)
Forwards the message from theCellEditor
to thedelegate
.boolean
stopCellEditing()
Forwards the message from theCellEditor
to thedelegate
.-
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, removeCellEditorListener
-
-
-
-
Field Detail
-
editorComponent
protected JComponent editorComponent
The Swing component being edited.
-
delegate
protected DefaultCellEditor.EditorDelegate delegate
The delegate class which handles all methods sent from theCellEditor
.
-
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 Detail
-
DefaultCellEditor
@ConstructorProperties(value="component") public DefaultCellEditor(JTextField textField)
Constructs aDefaultCellEditor
that uses a text field.- Parameters:
textField
- aJTextField
object
-
DefaultCellEditor
public DefaultCellEditor(JCheckBox checkBox)
Constructs aDefaultCellEditor
object that uses a check box.- Parameters:
checkBox
- aJCheckBox
object
-
DefaultCellEditor
public DefaultCellEditor(JComboBox comboBox)
Constructs aDefaultCellEditor
object that uses a combo box.- Parameters:
comboBox
- aJComboBox
object
-
-
Method Detail
-
getComponent
public Component 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()
-
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 getCellEditorValue()
Forwards the message from theCellEditor
to thedelegate
.- Specified by:
getCellEditorValue
in interfaceCellEditor
- 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
in interfaceCellEditor
- Overrides:
isCellEditable
in classAbstractCellEditor
- 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
in interfaceCellEditor
- Overrides:
shouldSelectCell
in classAbstractCellEditor
- 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
in interfaceCellEditor
- Overrides:
stopCellEditing
in classAbstractCellEditor
- Returns:
- true
- See Also:
DefaultCellEditor.EditorDelegate.stopCellEditing()
-
cancelCellEditing
public void cancelCellEditing()
Forwards the message from theCellEditor
to thedelegate
.- Specified by:
cancelCellEditing
in interfaceCellEditor
- Overrides:
cancelCellEditing
in classAbstractCellEditor
- 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
in 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 theTableCellEditor
interface.- Specified by:
getTableCellEditorComponent
in interfaceTableCellEditor
- 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 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
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/swing/DefaultCellEditor.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.