I have a jtree which is constructed initially. On some user action, the jtree has to be recreated. But, even though the jtree is re-created, it does not update on the panel. I am putting the jtree inside a scroll pane and then into the panel. I am first making jtree and the rootnode object null and initializing it again (for re-creating). Why is the jtree not getting updated? I prinited the jtree and it has the latest values, but still shows the old values on the panel (screen).
Thanks Nate. I used scrollpane.getViewport().setView(jtree) method to update the tree. After setting the view port, the tree does not scroll to the selected node. It scrolls to the top of the tree. Why is that? I am using setSelectionPath() and scrollPathToVisible() method but it does not scroll to selected node.
Take a look at the following code... It generates a tree model randomly... generate a new model a few times and you will see the last node is always selected and is always scrolled to visible. It should give you some pointers on what to do...
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
And then the entire population worshiped me like unto a god. Well, me and this tiny ad: