hi..i was refered by a teacher of mine to this site..hope i can learn many things here..=) i'm currently working on a project right now that aims to display the files and folders in a computer,one that works like a computer explorer/my computer function for windows users.i would like to use the JTree component in Swing to be able to display the files and folders of a computer so that it can be collapsed or expanded and its path can be displayed. i thought at first of using the JFileChooser for this function.But since JFileChooser is a dialog box,i would like to "put a JFileChooser" in a JTree to be able to dynamically browse through a computer's contents and display it as a tree. is there a class in java,besides JFileChooser,that can support this function?the one that can dynamically browse through a computer's contents?and one that can be displayed in a JTree/parent-children(folders-files) manner? we are limited to use swing components only.. hope i can get some useful feedbacks..tnx..=)
Welcome to JavaRanch, maxxinne! Please don't post the same question in multiple forums, 'round these parts. It just makes it difficult to follow a conversation. Moving this to the Swing / JFC / AWT forum...
JFileChooser and JTree have entirely different purposes so you will have to do some work to get them to play together. Looking at the workflow, the user will first use your JFileChooser to select a starting directory. You will then need to provide your JTree with an implementation of the TreeModel interface that can represent that directory and the files and directories contained within it as a tree. If you look at the Javadoc for JTree, TreeModel and DefaultTreeModel, there is a link to the Java tutorial on using trees. This is a good place to start. Have fun.
kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg