*
The moose likes Swing / AWT / SWT and the fly likes Swing components-JTree and JFileChooser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing components-JTree and JFileChooser" Watch "Swing components-JTree and JFileChooser" New topic
Author

Swing components-JTree and JFileChooser

maxxinne mine
Greenhorn

Joined: Feb 03, 2004
Posts: 3
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..=)
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Ken Krebs
Ranch Hand

Joined: Nov 27, 2002
Posts: 451
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
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Swing 2nd ed by Robinson & Vorobiev has an example of what you want.


SCJP2. Please Indent your code using UBB Code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing components-JTree and JFileChooser
 
Similar Threads
File Browser with JTree or JPanel
JTree
JTree Explorer with Desktop, My Computer, My Documents, My Network Places etc.
Computer Explorer(Swing Components-JFileChooser and JTree)
Computer Explorer(Swing Components-JTree and JFileChooser)