• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JTree help

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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....

Regards,
Anand
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Anand Loni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx,

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 ???
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic