Forums Register Login

Hiding nodes in a JTree

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
Yes, that sounds right. Create a new tree model which delegates all of its actions to the original tree model.
Fire me boy! Cool, soothing, shameless self promotion:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3108 times.
Similar Threads
Problems Sizing a JTree
JTree
Editable JTree????
JTree update patterns
JTree
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:46:11.