Solved

selecting whole directories in File Dialog window

Posted on 1998-04-27
7
364 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

621 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