Solved

selecting whole directories in File Dialog window

Posted on 1998-04-27
7
361 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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…
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.

776 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