| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public class DefaultTreeCellEditor extends Object implements ActionListener, TreeCellEditor, TreeSelectionListener
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 {@link java.beans.XMLEncoder}.
Nested Class Summary | |
---|---|
class |
TextField used when no editor is supplied. |
class |
Container responsible for placing the editingComponent . |
Field Summary | |
---|---|
protected Color |
borderSelectionColor
True if the border selection color should be drawn. |
protected boolean |
canEdit
As of Java 2 platform v1.4 this field should no longer be used. |
protected transient Component |
editingComponent
Component used in editing, obtained from the editingContainer . |
protected Container |
editingContainer
Editing container, will contain the editorComponent . |
protected transient Icon |
editingIcon
Icon to use when editing. |
protected Font |
font
Font to paint with, null indicates
font of renderer is to be used. |
protected transient TreePath |
lastPath
Last path that was selected. |
protected transient int |
lastRow
Row that was last passed into getTreeCellEditorComponent . |
protected transient int |
offset
Used in editing. |
protected TreeCellEditor |
realEditor
Editor handling the editing. |
protected DefaultTreeCellRenderer |
renderer
Renderer, used to get border and offsets from. |
protected transient Timer |
timer
Used before starting the editing session. |
protected transient JTree |
tree
JTree 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 |
Messaged when the timer fires, this will start the editing session. |
void |
Adds the CellEditorListener .
|
void |
Messages cancelCellEditing to the
realEditor and removes it from this instance.
|
protected boolean |
canEditImmediately(EventObject event) Returns true if event is null ,
or it is a MouseEvent with a click count > 2
and inHitRegion returns true.
|
protected Container |
Creates the container to manage placement of editingComponent .
|
protected TreeCellEditor |
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 |
Returns the color the border is drawn. |
CellEditorListener[] |
Returns an array of all the CellEditorListener s added
to this DefaultTreeCellEditor with addCellEditorListener().
|
Object |
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 realEditor returns true to this
message, prepareForEditing
is messaged and true is returned.
|
protected void |
Invoked just before editing is to start. |
void |
Removes the previously added CellEditorListener .
|
void |
setBorderSelectionColor(Color newColor) Sets the color to use for the border. |
void |
Sets the font to edit with. |
protected void |
Sets the tree currently editing for. |
boolean |
shouldSelectCell(EventObject event) Messages the realEditor for the return value.
|
protected boolean |
Returns true if event is a MouseEvent
and the click count is 1.
|
protected void |
Starts the editing timer. |
boolean |
If the realEditor will allow editing to stop,
the realEditor is removed and true is returned,
otherwise false is returned.
|
void |
Resets lastPath .
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Color borderSelectionColor
protected boolean canEdit
isCellEditable
.
protected transient Component editingComponent
editingContainer
.
protected Container editingContainer
editorComponent
.
protected transient Icon editingIcon
protected Font font
null
indicates
font of renderer is to be used.
protected transient TreePath lastPath
protected transient int lastRow
getTreeCellEditorComponent
.
protected transient int offset
editingComponent
.
protected TreeCellEditor realEditor
protected DefaultTreeCellRenderer renderer
protected transient Timer timer
protected transient JTree tree
JTree
instance listening too.
Constructor Detail |
---|
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
objectMethod Detail |
---|
public void actionPerformed(ActionEvent e)
e
public void addCellEditorListener(CellEditorListener l)
CellEditorListener
.
l
- the listener to be addedpublic void cancelCellEditing()
cancelCellEditing
to the
realEditor
and removes it from this instance.
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 Container createContainer()
editingComponent
.
protected TreeCellEditor createTreeCellEditor()
TreeCellEditor
is not supplied in the constructor.
It returns a TextField
editor.
TextField
editorprotected void determineOffset(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
tree
value
isSelected
expanded
leaf
row
public Color getBorderSelectionColor()
public CellEditorListener[] getCellEditorListeners()
CellEditorListener
s added
to this DefaultTreeCellEditor with addCellEditorListener().
CellEditorListener
s added or an empty
array if no listeners have been addedpublic Object getCellEditorValue()
public Font getFont()
Font
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
realEditor
.
tree
value
isSelected
expanded
leaf
row
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.
x
- the x-coordinate of the pointy
- the y-coordinate of the pointpublic boolean isCellEditable(EventObject event)
realEditor
returns true to this
message, prepareForEditing
is messaged and true is returned.
event
protected void prepareForEditing()
editingComponent
to the
editingContainer
.
public void removeCellEditorListener(CellEditorListener l)
CellEditorListener
.
l
- the listener to be removedpublic void setBorderSelectionColor(Color newColor)
newColor
- the new border colorpublic 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 Font
protected void setTree(JTree newTree)
newTree
- the new tree to be editedpublic boolean shouldSelectCell(EventObject event)
realEditor
for the return value.
event
protected boolean shouldStartEditingTimer(EventObject event)
event
is a MouseEvent
and the click count is 1.
event
- the event being studiedprotected void startEditingTimer()
public boolean stopCellEditing()
realEditor
will allow editing to stop,
the realEditor
is removed and true is returned,
otherwise false is returned.
public void valueChanged(TreeSelectionEvent e)
lastPath
.
e
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |