I don't know if it is possible to get the "My Computer" as root, but check this out:
File [] files = File.listRoots();
for (int i=0;i<files.length;i++) {
System.out.println(files[i]);
}
This will get you all the files that are under the "My Computer". So instead of having one root ("C:/program files"),
you can create one father, and under that father put as nodes the "Files" that the above code returns:
C://, E://, D://
I don't know if it makes sense, but you can have this:
root = new DefaultMutableTreeNode("root", true);
File fList[] = File.listRoots();
for(int i = 0; i < fList.length; i++)
getList(root , fList[i]);
}
After all, under "My Computer", all you have are the drives of your computer: C:/, D:/
Also you can check this tutorial:
http://java.sun.com/docs/books/tutor...ents/tree.html
And I would suggest not to populate the tree recursively because it takes awfully long. Try to put Listeners and when a folder is clicked, then take and add the children.
Question: Have you tried JFileChooser?