You can customize JFileChooser to show and allow selection of only directories/folders. Check out these JDC Tech Tips on customizing JFileChooser. You can setFileSelectionMode to JFileChooser.DIRECTORIES_ONLY - which allows the user to only select directories, and not files. To not show files at all, you will also need to create a FileFilter that filters out all files and shows all directories and pass it to setFileFilter.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
posted 12 years ago
listing dirctory as a tree is the target and filechooser does not give this target
You could create your own implementation of javax.swing.tree.TreeModel that deals with Files. For instance, "public int getChildCount(Object parent)" would cast parent to a File, calls listFiles() and returns the length of this array (or 0 if the array is null).
Just one hint: if you go this way, cache the arrays. If not, and you again call listFiles() in "public Object getChild(Object parent, int index)", then you will call listFiles() for each and every node in the tree. I did it this way before, and it took minutes to show a folder with 1000+ files.
You can also use File.listFiles(FileFilter) to limit the files you get as a return value.