Results 1 to 2 of 2
Thread: JTree not expanding?
- 04-14-2011, 10:44 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 25
- Rep Power
- 0
JTree not expanding?
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.
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.Java Code: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,
cheers!
- 04-14-2011, 04:27 PM #2
Member
- Join Date
- Mar 2011
- Posts
- 25
- Rep Power
- 0
Similar Threads
-
JPanel shrinking-expanding problem
By eLancaster in forum New To JavaReplies: 4Last Post: 04-14-2011, 05:48 PM -
text areas expanding
By aizen92 in forum New To JavaReplies: 5Last Post: 03-20-2011, 08:51 PM -
JFrame expanding to fit content
By pcman312 in forum AWT / SwingReplies: 1Last Post: 12-31-2010, 07:09 PM -
Move JTree item to another JTree.
By Melki in forum AWT / SwingReplies: 8Last Post: 07-09-2009, 11:59 AM -
dynamically expanding byte container?
By dfens in forum New To JavaReplies: 1Last Post: 07-03-2009, 10:27 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks