I have a jtree with nodes that when right clicked pops up a menu to rename the nodes. This works fine, my problem is since i have to set the setEditable(true), the tree also allows users to edit it by clicking 3 times or by pressing F2 key. I need to be able to disable these and allow edit only via the popup menu.. any suggestions???
Why not make all nodes non-editable. Then when you choose the right menu option on a node, temporarily make it editable (you must know which node you clicked on or you wouldn't be able to rename it), and then after the rename set it to non-editable again.
Originally posted by Sudhakar Krishnamurthy: Thanks Gregg, If you see the last line in the code, i am setting the tree to be non-editable...or should i move that up into the action performed method???
About F2, its one of the lame requirements that we have
Yes. What is happening is that setEditable(false) call is being called when you run the program. The actionPerformed block is the only thing that gets executed on the action. So when you click on the context menu action, it doesn't touch anything but the code in the event block.
Gregg: I tried moving the setEditable(false) into the actionPerformed method as the last statement to be executed and now i just can't edit it...although i get the popup...hmmm its as though even before i can start editing the tree is being set back to non-editable... I have this entire piece of code in the mouseReleased method, if that helps.