Solved

selecting whole directories in File Dialog window

Posted on 1998-04-27
7
362 Views
Last Modified: 2012-05-04
How can I modify the standard java FileDialog frame so that the user can select multiple files and/or whole directories?
0
Comment
Question by:margaretr
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:dufort
ID: 1220061
You cannot. This dialog is system-dependant, and until Java designers don't add these functionalities to the API, it is simply impossible to choose a simple directory.

I faced this problem too, and found it annoying.

What we have to do is probably to design a directory chooser. I'll try and let you know.

0
 

Author Comment

by:margaretr
ID: 1220062
Thanks.  That is annoying.

What do you mean by a directory chooser?
0
 

Author Comment

by:margaretr
ID: 1220063
Thanks.  That is annoying.

What do you mean by a directory chooser?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:dufort
ID: 1220064
I'm designing dialog box for selecting a directory (and implicitely its whole content). Coupled with a multi-selection JList, this will do the job.

(I'm using Swing classes, not AWT classes. Hope you are too.)

0
 
LVL 1

Expert Comment

by:dufort
ID: 1220065
I give up. I looked the "bug parade" at Sun's developers connection, and there is very long discussion about this problem and about the impossibility of listing installed disks (C:, D:, ...) in Java.

This won't even be included in JDK 1.2.0.

0
 

Author Comment

by:margaretr
ID: 1220066
I just saw that discussion, too.  Pretty disappointing.
0
 
LVL 1

Accepted Solution

by:
blacklion earned 100 total points
ID: 1220067
No, of course you cannot modify standard FileDialog to choose directories.
But there is temporary solution that I use and, for example, JBuilder uses too.
You should just set some file name to the dialog before show it. So, user should not enter
some file name manually and can consentrate on selecting directory.
For instance:

FileDialog fd = new FileDialog (this, "Select some folder", FileDialog.OPEN);
fd.setFile ("Some.Folder"); // to avoid manually enter the file name
fd.setDirectory (lastUsedDirectory);
fd.show();
if (fd.getFile() != null)
{
  // user selected the directory
  String direcory = fd.getDirectory();
}

AFAIK, this is the only way to do it, unfortunately not so nice, but it works.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 65
servlet filter example 37 72
ejb stateless example 2 27
IBM TS2900 (3572) Tape Autoloader Java? 10 13
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

830 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