| 
 | JavaTM 2 Platform Std. Ed. v1.3.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--javax.swing.tree.DefaultTreeCellEditor
A TreeCellEditor. You need to supply an instance of DefaultTreeCellRenderer so that the icons can be obtained. You can optionaly 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. A future release of Swing will provide support for long term persistence.
JTree| Inner Class Summary | |
|  class | DefaultTreeCellEditor.DefaultTextFieldTextField used when no editor is supplied. | 
|  class | DefaultTreeCellEditor.EditorContainerContainer responsible for placing the editingComponent. | 
| Field Summary | |
| protected  Color | borderSelectionColorTrue if the border selection color should be drawn. | 
| protected  boolean | canEditShould isCellEditable return true? This is set in configure... | 
| 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, null indicates 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 | treeJTree instance listening too. | 
| Constructor Summary | |
| DefaultTreeCellEditor(JTree tree,
                      DefaultTreeCellRenderer renderer)Constructs a DefaultTreeCellEditor object for a JTree using the specified renderer and a default editor. | |
| DefaultTreeCellEditor(JTree tree,
                      DefaultTreeCellRenderer renderer,
                      TreeCellEditor editor)Constructs a DefaultTreeCellEditor object for a JTree using the specified renderer and the specified editor. | |
| Method Summary | |
|  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 cancelCellEditing to the realEditor and removes it from this instance. | 
| protected  boolean | canEditImmediately(EventObject event)Returns true if eventis null, or it is a MouseEvent
 with a click count > 2 and inHitRegion returns true. | 
| protected  Container | createContainer()Creates the container to manage placement of editingComponent. | 
| protected  TreeCellEditor | createTreeCellEditor()This is invoked if a TreeCellEditor is 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. | 
|  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)Should return true if the passed in location is a valid mouse location to start editing from. | 
|  boolean | isCellEditable(EventObject event)If the realEditor returns true to this message, prepareForEditing is messaged and true is returned. | 
| protected  void | prepareForEditing()Invoked just before editing is to start. | 
|  void | removeCellEditorListener(CellEditorListener l)Removes the previously added CellEditorListener l. | 
|  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 realEditor for the return value. | 
| protected  boolean | shouldStartEditingTimer(EventObject event)Returns true if eventis a MouseEvent and the click
 count is 1. | 
| protected  void | startEditingTimer()Starts the editing timer. | 
|  boolean | stopCellEditing()If the realEditor will allow editing to stop, the realEditor is removed and true is returned, otherwise false is returned. | 
|  void | valueChanged(TreeSelectionEvent e)Resets lastPath. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
protected TreeCellEditor realEditor
protected DefaultTreeCellRenderer renderer
protected Container editingContainer
protected transient Component editingComponent
protected boolean canEdit
protected transient int offset
protected transient JTree tree
protected transient TreePath lastPath
protected transient Timer timer
protected transient int lastRow
protected Color borderSelectionColor
protected transient Icon editingIcon
protected Font font
| Constructor Detail | 
public DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer)
tree - a JTree objectrenderer - a DefaultTreeCellRenderer objectpublic DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer, TreeCellEditor editor)
tree - a JTree objectrenderer - a DefaultTreeCellRenderer objecteditor - a TreeCellEditor object| Method Detail | 
public void setBorderSelectionColor(Color newColor)
public Color getBorderSelectionColor()
public void setFont(Font font)
font - the editing FontgetFont()public Font getFont()
setFont(java.awt.Font)public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
getTreeCellEditorComponent in interface TreeCellEditorjavax.swing.tree.TreeCellEditortable - 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 is the cell is to be renderer 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)
isCellEditable in interface CellEditorjavax.swing.CellEditoranEvent - the event the editor should use to consider
				whether to begin editing or not.CellEditor.shouldSelectCell(java.util.EventObject)public boolean shouldSelectCell(EventObject event)
shouldSelectCell in interface CellEditorjavax.swing.CellEditoranEvent - the event the editor should use to start
				editing.CellEditor.isCellEditable(java.util.EventObject)public boolean stopCellEditing()
stopCellEditing in interface CellEditorjavax.swing.CellEditorpublic void cancelCellEditing()
cancelCellEditing in interface CellEditorpublic void addCellEditorListener(CellEditorListener l)
addCellEditorListener in interface CellEditorjavax.swing.CellEditorl - the CellEditorListenerpublic void removeCellEditorListener(CellEditorListener l)
removeCellEditorListener in interface CellEditorjavax.swing.CellEditorl - the CellEditorListenerpublic void valueChanged(TreeSelectionEvent e)
valueChanged in interface TreeSelectionListenerjavax.swing.event.TreeSelectionListenere - the event that characterizes the change.public void actionPerformed(ActionEvent e)
actionPerformed in interface ActionListenerprotected void setTree(JTree newTree)
protected boolean shouldStartEditingTimer(EventObject event)
event is a MouseEvent and the click
 count is 1.protected void startEditingTimer()
protected boolean canEditImmediately(EventObject event)
event is null, or it is a MouseEvent
 with a click count > 2 and inHitRegion returns true.
protected 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.protected void determineOffset(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
protected void prepareForEditing()
editingComponent to the
 editingContainer.protected Container createContainer()
protected TreeCellEditor createTreeCellEditor()
| 
 | JavaTM 2 Platform Std. Ed. v1.3.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A.  All Rights Reserved.