Solved

Select a directory in a FileDialog?

Posted on 1998-09-03
2
2,053 Views
Last Modified: 2008-02-01
I'm trying to use a FileDialog to allow a user to choose a specific directory instead of a file.  How do I make the dialog allow a directory to be chosen and return the name of the directory (so I can use it as a File object) instead of simply opening the directory and listing its contents?  I've tried creating a new FilenameFilter and passing it to the FileDialog using setFilenameFilter, but it didn't work.

Do I need to go about this some other way?

I'm using Java 1.1 on Win95.
0
Comment
Question by:oucher
[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
2 Comments
 
LVL 4

Expert Comment

by:evijay
ID: 1223556
you have to write your own or use swing (jfc) jfilechooser which allows you to do that

0
 
LVL 3

Accepted Solution

by:
sailwind earned 50 total points
ID: 1223557
Evijay is right. You will have to create a new filechooser in order to
specify that you want to get a directory instead of opening it.

Swing now comes with a much more robust file chooser dialog. You can
check it out here:

http://java.sun.com/products/jfc/tsc/swingdoc-current/file_chooser.html#

You should be able to find what you need at this page.
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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.

728 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