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 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
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DefaultTreeCellEditor.DefaultTextField | TextField used when no editor is supplied. |
||||||||||
DefaultTreeCellEditor.EditorContainer | Container responsible for placing the editingComponent . |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
borderSelectionColor | True if the border selection color should be drawn. | ||||||||||
canEdit | As of Java 2 platform v1.4 this field should no longer be used. | ||||||||||
editingComponent | Component used in editing, obtained from the
editingContainer . |
||||||||||
editingContainer | Editing container, will contain the editorComponent . |
||||||||||
editingIcon | Icon to use when editing. | ||||||||||
font | Font to paint with, null indicates
font of renderer is to be used. |
||||||||||
lastPath | Last path that was selected. | ||||||||||
lastRow | Row that was last passed into
getTreeCellEditorComponent . |
||||||||||
offset | Used in editing. | ||||||||||
realEditor | Editor handling the editing. | ||||||||||
renderer | Renderer, used to get border and offsets from. | ||||||||||
timer | Used before starting the editing session. | ||||||||||
tree | JTree instance listening too. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a
DefaultTreeCellEditor
object for a JTree using the specified renderer and
a default editor. | |||||||||||
Constructs a
DefaultTreeCellEditor
object for a JTree using the
specified renderer and the specified editor. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Messaged when the timer fires, this will start the editing
session.
| |||||||||||
Adds the
CellEditorListener . | |||||||||||
Messages
cancelCellEditing to the
realEditor and removes it from this instance. | |||||||||||
Returns the color the border is drawn.
| |||||||||||
Returns an array of all the
CellEditorListener s added
to this DefaultTreeCellEditor with addCellEditorListener(). | |||||||||||
Returns the value currently being edited.
| |||||||||||
Gets the font used for editing.
| |||||||||||
Configures the editor.
| |||||||||||
If the
realEditor returns true to this
message, prepareForEditing
is messaged and true is returned. | |||||||||||
Removes the previously added
CellEditorListener . | |||||||||||
Sets the color to use for the border.
| |||||||||||
Sets the font to edit with.
| |||||||||||
Messages the
realEditor for the return value. | |||||||||||
If the
realEditor will allow editing to stop,
the realEditor is removed and true is returned,
otherwise false is returned. | |||||||||||
Resets
lastPath . |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns true if
event is null ,
or it is a MouseEvent with a click count > 2
and inHitRegion returns true. | |||||||||||
Creates the container to manage placement of
editingComponent . | |||||||||||
This is invoked if a
TreeCellEditor
is not supplied in the constructor. | |||||||||||
Returns true if the passed in location is a valid mouse location
to start editing from.
| |||||||||||
Invoked just before editing is to start.
| |||||||||||
Sets the tree currently editing for.
| |||||||||||
Returns true if
event is a MouseEvent
and the click count is 1. | |||||||||||
Starts the editing timer.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
As of Java 2 platform v1.4 this field should no longer be used. If
you wish to provide similar behavior you should directly override
isCellEditable
.
Row that was last passed into
getTreeCellEditorComponent
.
Used in editing. Indicates x position to place
editingComponent
.
Constructs a DefaultTreeCellEditor
object for a JTree using the specified renderer and
a default editor. (Use this constructor for normal editing.)
tree | a JTree object |
---|---|
renderer | a DefaultTreeCellRenderer object
|
Constructs a DefaultTreeCellEditor
object for a JTree
using the
specified renderer and the specified editor. (Use this constructor
for specialized editing.)
tree | a JTree object |
---|---|
renderer | a DefaultTreeCellRenderer object |
editor | a TreeCellEditor object
|
Messaged when the timer fires, this will start the editing session.
Adds the CellEditorListener
.
l | the listener to be added |
---|
Messages cancelCellEditing
to the
realEditor
and removes it from this instance.
Returns the color the border is drawn.
Returns an array of all the CellEditorListener
s added
to this DefaultTreeCellEditor with addCellEditorListener().
CellEditorListener
s added or an empty
array if no listeners have been addedReturns the value currently being edited.
Configures the editor. Passed onto the realEditor
.
tree | 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 if the cell is to be rendered with selection highlighting |
expanded | true if the node is expanded |
leaf | true if the node is a leaf node |
row | the row index of the node being edited |
If the realEditor
returns true to this
message, prepareForEditing
is messaged and true is returned.
event | the event the editor should use to consider whether to begin editing or not |
---|
Removes the previously added CellEditorListener
.
l | the listener to be removed |
---|
Sets the color to use for the border.
newColor | the new border color |
---|
Sets the font to edit with. 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 Font |
---|
Messages the realEditor
for the return value.
event | the event the editor should use to start editing |
---|
If the realEditor
will allow editing to stop,
the realEditor
is removed and true is returned,
otherwise false is returned.
Resets lastPath
.
e | the event that characterizes the change. |
---|
Returns true if event
is null
,
or it is a MouseEvent
with a click count > 2
and inHitRegion
returns true.
event | the event being studied |
---|
Creates the container to manage placement of
editingComponent
.
This is invoked if a TreeCellEditor
is not supplied in the constructor.
It returns a TextField
editor.
TextField
editor
Returns true if the passed in location is a valid mouse location
to start editing from. This is implemented to return false if
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 point |
---|---|
y | the y-coordinate of the point |
Invoked just before editing is to start. Will add the
editingComponent
to the
editingContainer
.
Sets the tree currently editing for. This is needed to add a selection listener.
newTree | the new tree to be edited |
---|
Returns true if event
is a MouseEvent
and the click count is 1.
event | the event being studied |
---|
Starts the editing timer.