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 }