Greetings,
I have a small method that removes all branches and leaves from a tree and then adds them all again (because one has changed). At the end it should expand the treePath to the leaf that changed, but it doesn't.
Code:
The addToTree method adds all the branches and leaves back, and works fine, after all the code has finished my tree is all there, laid out properly, but it's all collapsed.TreePath openNode = pathToLeaf().getParentPath(); DefaultTreeModel model = (DefaultTreeModel)myTree.getModel(); Object root = model.getRoot(); for (int i=0; i<model.getChildCount(root); i++) { MutableTreeNode child = (MutableTreeNode)model.getChild(root, i); model.removeNodeFromParent(child); } model.setRoot(null); model.setRoot(addToTree(null, new File(installedDir + "/projects"))); myTree.expandPath(openNode); System.out.println(myTree.isExpanded(openNode));
Even more interestingly, the program returns myTree.isExpanded as true, but it isn't???
Am I missing something?
Any help would be appreciated,
P.S. Sorry if this is in the wrong section, I wasn't sure if I should post it here or in the Swing section
cheers!