Solved

How to create directory tree in java?

Posted on 2007-04-05
4
3,808 Views
Last Modified: 2013-12-22
Anyone know how to create a directory tree using swing in Java?This tree is used for scaning all computer hard drive and directories inside each drive.
0
Comment
Question by:khoama
  • 2
4 Comments
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
You can use a JFileChooser to select files in any directory if that is what you want.

http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html

Otherwise you ca create a JTree to represent your existing folder structure.

http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
0
 
LVL 2

Author Comment

by:khoama
Comment Utility
I known all your solutions already.What I need is using java swing JTree to implement a directory tree.I have some examples but they are difficult to understand and implement.Is there any easier way?
0
 
LVL 1

Accepted Solution

by:
alban4 earned 500 total points
Comment Utility
Try using the class javax.swing.filechooser.FileSystemView to build you JTree:
- getRoots() provides an array of file roots
- getFiles() returns all children of a given node (you will need to filter out non directories)
- getSystemIcon() returns the icon to use for a given node
0
 
LVL 2

Author Comment

by:khoama
Comment Utility
thanks for the solution, I will try it.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now