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 ]
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.
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.
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
a bit of art, as a gift, the permaculture playing cards