Forums Register Login

JTree collapses after sorting

+Pie Number of slices to send: Send
Hi, I am facing a problem as described below:
A new node is added to JTree and then I am sorting the nodes. After sorting completes, I want the newly added node should be highlighted. I used parent path of the new added node and called jtree.scrollPathToVisible(parentPath); jtree.setSelectionPath(parentPath);. but its not working. Please help
+Pie Number of slices to send: Send
As you are calling setSelectionPath on the parent node, logically, the parent would be selected. If you want the parent to be expanded, then you should call expandPath().
+Pie Number of slices to send: Send
Thank you for your reply. I tried calling jTree.expandPath(parentPath); and jTree.makeVisible(parentPath); but still it collapses.
+Pie Number of slices to send: Send
Ok, then, you will have to create a small runnable program that reproduces the problem and post the code. This is called SSCCE. Volunteers here can then take that program and run it and see.
Are you here to take over the surface world? Because this tiny ad will stop you!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 582 times.
Similar Threads
JTree collapsed after refresh
Refreshing JTree
sorting jtree
collapsing JTree
JTree
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:14:54.