Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to create directory tree in java?

Posted on 2007-04-05
4
Medium Priority
?
3,845 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 18860742
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
ID: 18862730
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 1500 total points
ID: 18865661
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
ID: 18868309
thanks for the solution, I will try it.
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

688 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