views:

65

answers:

1

I'm using the class "DynamicTree" provided by sun:here is the link

I wanted to know if it's possible to edit the code in some way to make the tree root name editable.

+1  A: 

You can make the tree node editable by modifying tree properties, i.e you need to make the tree editable by making this code change: tree.setEditable(true)

But note that with this change the rename of node is possible (for the demo code referred in the tutorial) by pressing the F2 key.

sateesh
Are you saying that this can only be done with the user action and cannot be done programatically?
Ahmad Hajou
What I meant is, you can change the code to add the line I have mentioned. Once this modification is done the users can change the names of tree nodes. Tree nodes will be editable and the users can rename the tree node by pressing F2 key.
sateesh
I wish to obtain a certain tree from a data source and display it, im having trouble editing the root node programatically.This is initiated by a user action, and can be done multiple times.(I many need to re-populate the tree.)Please let me know if this can be done.
Ahmad Hajou
What you want to do is possible: you need to have a TreeModel, a listener that listens to the user actions and based on your requirements you may have to also have a TreeCellRenderer and TreeCellEditor as well. By going through the Java Swing tutorial, I would say you are in right track. Try the approach explained in the tutorial and seek help when you face any issues.
sateesh