Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree collapses after sorting  RSS feed

 
Sanjoo Singh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
Sanjoo Singh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply. I tried calling jTree.expandPath(parentPath); and jTree.makeVisible(parentPath); but still it collapses.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!