• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Hiding nodes in a JTree

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am importing a tree from another program. But in my new program, I don't want to display every node of the tree. I created a class called SimContainerNode that holds the DefaultMutableTreeNodes of the old tree, and adds some fields such as frequency, and isVisible. When I display the JTree, I only want the nods with isVisible = true to show up. How can I acheive this?

I am currently looking into implementing my own Tree Cell Renderer.
 
Marshal
Posts: 27214
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does "hiding" mean?

Do you want the tree to appear as if those nodes don't even exist? Or do you want them to take up space, but to just display as blank space?

If it's the former, you'll need a tree model which suppresses the invisible nodes completely. If it's the latter, a tree cell renderer might work.
 
John Danek
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was actually hoping to make it appear they don't even exist, but I have a new idea. The parts I want to show from the old tree are all contained in the same node, so I will simply use this as the node for the new tree. Hopefully I'm able to make changes to the old tree based on selections in the new tree.

Thanks for your help!
 
Paul Clapham
Marshal
Posts: 27214
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that sounds right. Create a new tree model which delegates all of its actions to the original tree model.
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic