Solved

selecting whole directories in File Dialog window

Posted on 1998-04-27
7
358 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
Comment Utility
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
Comment Utility
Thanks.  That is annoying.

What do you mean by a directory chooser?
0
 

Author Comment

by:margaretr
Comment Utility
Thanks.  That is annoying.

What do you mean by a directory chooser?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:dufort
Comment Utility
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
Comment Utility
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
Comment Utility
I just saw that discussion, too.  Pretty disappointing.
0
 
LVL 1

Accepted Solution

by:
blacklion earned 100 total points
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

762 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

11 Experts available now in Live!

Get 1:1 Help Now