This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I am using Jtree with DefaultTreeModel and whose nodes are DefaultMutableTreeNode. I have associated JpopupMenu with tree. When I click rename from popup I want to make the selected tree node editable. Is there any method to do this ? AnyBody can Help....
Since the tree is using a DefaultTreeModel and is editable the default editor is DefaultTreeCellEditor. See the discussion section of this class for the two gestures that trigger editing. Use of the popupMenu button makes three. Press the "enter" key after the edit to save the new value to the model.
edit words at top for clarity [ February 24, 2006: Message edited by: Craig Wood ]
Joined: Jan 20, 2006
This code is Ok , I found the method startEditingAt() but when I start editing popup is not displayed(in my case it should show same popup when we do not edit node). Also I have set CellRenderer for tree to do not show icon and for some other purpose ,then also it is showing icon for editing node.
why this is happening ???
Joined: Jan 14, 2004
when I start editing popup is not displayed You can locate it wherever you want and call setVisible to keep it there. Or you can move it around:
CellRenderer for tree to ... not show icon You can make up an editor to match your CellRenderer. If you use DefaultTreeCellEditor it has a constructor in which you can specify your renderer as an argument, see api.