The Artima Developer Community
Sponsored Link

Java Answers Forum
how can i dynamically change a JTree root

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
shi bo luo

Posts: 5
Nickname: seafarer
Registered: Nov, 2002

how can i dynamically change a JTree root Posted: Dec 4, 2002 9:25 PM
Reply to this message Reply
Advertisement
i want to display my file system using a JTree.Given the certain root,it does work.but when i change the root directory,the tree is the same one.the code listed below in summary:

public class MyFileTree{
/*
*....some code
*
*/
public void populateTree(File rootDir){...};
public JTree getTree(){.....};
....
public static void main(){
JTree myTree;
//some swing code to display the tree
.......
File rootDir=new File("D:");
File newDir=new File("F:");
MyFileTree aTree=new MyFileTree()
aTree.populateTree(rootDir);
myTree=aTree.getTree();//this does work

//attempt to change its view using a trigger
//such as a button
aTree.populateTree(newDir);
myTree=aTree.getTree();//it seems no change
}

who can tell me why.
thank you in advance.

Topic: help Previous Topic   Next Topic Topic: Adjusting a Date object in Visual Age for Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use