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

x
?
Solved

selecting whole directories in File Dialog window

Posted on 1998-04-27
7
Medium Priority
?
365 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
[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
  • 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
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.

 
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 200 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

715 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