public class DefaultTreeCellEditor extends Object implements ActionListener, TreeCellEditor, TreeSelectionListener
TreeCellEditor. You need to supply an
 instance of DefaultTreeCellRenderer
 so that the icons can be obtained. You can optionally supply
 a TreeCellEditor that will be layed out according
 to the icon in the DefaultTreeCellRenderer.
 If you do not supply a TreeCellEditor,
 a TextField will be used. Editing is started
 on a triple mouse click, or after a click, pause, click and
 a delay of 1200 miliseconds.
 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 see XMLEncoder.
JTree| Modifier and Type | Class and Description | 
|---|---|
| class  | DefaultTreeCellEditor.DefaultTextFieldTextFieldused when no editor is supplied. | 
| class  | DefaultTreeCellEditor.EditorContainerContainer responsible for placing the  editingComponent. | 
| Modifier and Type | Field and Description | 
|---|---|
| protected Color | borderSelectionColorTrue if the border selection color should be drawn. | 
| protected boolean | canEditAs of Java 2 platform v1.4 this field should no longer be used. | 
| protected Component | editingComponentComponent used in editing, obtained from the
  editingContainer. | 
| protected Container | editingContainerEditing container, will contain the  editorComponent. | 
| protected Icon | editingIconIcon to use when editing. | 
| protected Font | fontFont to paint with,  nullindicates
 font of renderer is to be used. | 
| protected TreePath | lastPathLast path that was selected. | 
| protected int | lastRowRow that was last passed into
  getTreeCellEditorComponent. | 
| protected int | offsetUsed in editing. | 
| protected TreeCellEditor | realEditorEditor handling the editing. | 
| protected DefaultTreeCellRenderer | rendererRenderer, used to get border and offsets from. | 
| protected Timer | timerUsed before starting the editing session. | 
| protected JTree | treeJTreeinstance listening too. | 
| Constructor and Description | 
|---|
| DefaultTreeCellEditor(JTree tree,
                     DefaultTreeCellRenderer renderer)Constructs a  DefaultTreeCellEditorobject for a JTree using the specified renderer and
 a default editor. | 
| DefaultTreeCellEditor(JTree tree,
                     DefaultTreeCellRenderer renderer,
                     TreeCellEditor editor)Constructs a  DefaultTreeCellEditorobject for aJTreeusing the
 specified renderer and the specified editor. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | actionPerformed(ActionEvent e)Messaged when the timer fires, this will start the editing
 session. | 
| void | addCellEditorListener(CellEditorListener l)Adds the  CellEditorListener. | 
| void | cancelCellEditing()Messages  cancelCellEditingto therealEditorand removes it from this instance. | 
| protected boolean | canEditImmediately(EventObject event)Returns true if  eventisnull,
 or it is aMouseEventwith a click count > 2
 andinHitRegionreturns true. | 
| protected Container | createContainer()Creates the container to manage placement of
  editingComponent. | 
| protected TreeCellEditor | createTreeCellEditor()This is invoked if a  TreeCellEditoris not supplied in the constructor. | 
| protected void | determineOffset(JTree tree,
               Object value,
               boolean isSelected,
               boolean expanded,
               boolean leaf,
               int row) | 
| Color | getBorderSelectionColor()Returns the color the border is drawn. | 
| CellEditorListener[] | getCellEditorListeners()Returns an array of all the  CellEditorListeners added
 to this DefaultTreeCellEditor with addCellEditorListener(). | 
| Object | getCellEditorValue()Returns the value currently being edited. | 
| Font | getFont()Gets the font used for editing. | 
| Component | getTreeCellEditorComponent(JTree tree,
                          Object value,
                          boolean isSelected,
                          boolean expanded,
                          boolean leaf,
                          int row)Configures the editor. | 
| protected boolean | inHitRegion(int x,
           int y)Returns true if the passed in location is a valid mouse location
 to start editing from. | 
| boolean | isCellEditable(EventObject event)If the  realEditorreturns true to this
 message,prepareForEditingis messaged and true is returned. | 
| protected void | prepareForEditing()Invoked just before editing is to start. | 
| void | removeCellEditorListener(CellEditorListener l)Removes the previously added  CellEditorListener. | 
| void | setBorderSelectionColor(Color newColor)Sets the color to use for the border. | 
| void | setFont(Font font)Sets the font to edit with. | 
| protected void | setTree(JTree newTree)Sets the tree currently editing for. | 
| boolean | shouldSelectCell(EventObject event)Messages the  realEditorfor the return value. | 
| protected boolean | shouldStartEditingTimer(EventObject event)Returns true if  eventis aMouseEventand the click count is 1. | 
| protected void | startEditingTimer()Starts the editing timer. | 
| boolean | stopCellEditing()If the  realEditorwill allow editing to stop,
 therealEditoris removed and true is returned,
 otherwise false is returned. | 
| void | valueChanged(TreeSelectionEvent e)Resets  lastPath. | 
protected TreeCellEditor realEditor
protected DefaultTreeCellRenderer renderer
protected Container editingContainer
editorComponent.protected transient Component editingComponent
editingContainer.protected boolean canEdit
isCellEditable.protected transient int offset
editingComponent.protected transient JTree tree
JTree instance listening too.protected transient TreePath lastPath
protected transient Timer timer
protected transient int lastRow
getTreeCellEditorComponent.protected Color borderSelectionColor
protected transient Icon editingIcon
protected Font font
null indicates
 font of renderer is to be used.public DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer)
DefaultTreeCellEditor
 object for a JTree using the specified renderer and
 a default editor. (Use this constructor for normal editing.)tree - a JTree objectrenderer - a DefaultTreeCellRenderer objectpublic DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer, TreeCellEditor editor)
DefaultTreeCellEditor
 object for a JTree using the
 specified renderer and the specified editor. (Use this constructor
 for specialized editing.)tree - a JTree objectrenderer - a DefaultTreeCellRenderer objecteditor - a TreeCellEditor objectpublic void setBorderSelectionColor(Color newColor)
newColor - the new border colorpublic Color getBorderSelectionColor()
public void setFont(Font font)
null indicates
 the renderers font should be used. This will NOT
 override any font you have set in the editor
 the receiver was instantied with. If null
 for an editor was passed in a default editor will be
 created that will pick up this font.font - the editing FontgetFont()public Font getFont()
FontsetFont(java.awt.Font)public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
realEditor.getTreeCellEditorComponent in interface TreeCellEditortree - 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 editedpublic Object getCellEditorValue()
getCellEditorValue in interface CellEditorpublic boolean isCellEditable(EventObject event)
realEditor returns true to this
 message, prepareForEditing
 is messaged and true is returned.isCellEditable in interface CellEditorevent - the event the editor should use to consider
                          whether to begin editing or notCellEditor.shouldSelectCell(java.util.EventObject)public boolean shouldSelectCell(EventObject event)
realEditor for the return value.shouldSelectCell in interface CellEditorevent - the event the editor should use to start
                          editingCellEditor.isCellEditable(java.util.EventObject)public boolean stopCellEditing()
realEditor will allow editing to stop,
 the realEditor is removed and true is returned,
 otherwise false is returned.stopCellEditing in interface CellEditorpublic void cancelCellEditing()
cancelCellEditing to the
 realEditor and removes it from this instance.cancelCellEditing in interface CellEditorpublic void addCellEditorListener(CellEditorListener l)
CellEditorListener.addCellEditorListener in interface CellEditorl - the listener to be addedpublic void removeCellEditorListener(CellEditorListener l)
CellEditorListener.removeCellEditorListener in interface CellEditorl - the listener to be removedpublic CellEditorListener[] getCellEditorListeners()
CellEditorListeners added
 to this DefaultTreeCellEditor with addCellEditorListener().CellEditorListeners added or an empty
         array if no listeners have been addedpublic void valueChanged(TreeSelectionEvent e)
lastPath.valueChanged in interface TreeSelectionListenere - the event that characterizes the change.public void actionPerformed(ActionEvent e)
actionPerformed in interface ActionListenerprotected void setTree(JTree newTree)
newTree - the new tree to be editedprotected boolean shouldStartEditingTimer(EventObject event)
event is a MouseEvent
 and the click count is 1.event - the event being studiedprotected void startEditingTimer()
protected boolean canEditImmediately(EventObject event)
event is null,
 or it is a MouseEvent with a click count > 2
 and inHitRegion returns true.event - the event being studiedprotected boolean inHitRegion(int x,
                  int y)
x is <= the width of the icon and icon gap displayed
 by the renderer. In other words this returns true if the user
 clicks over the text part displayed by the renderer, and false
 otherwise.x - the x-coordinate of the pointy - the y-coordinate of the pointprotected void determineOffset(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
protected void prepareForEditing()
editingComponent to the
 editingContainer.protected Container createContainer()
editingComponent.protected TreeCellEditor createTreeCellEditor()
TreeCellEditor
 is not supplied in the constructor.
 It returns a TextField editor.TextField editor 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, 2012, Oracle and/or its affiliates.  All rights reserved.