Solved

Select a directory in a FileDialog?

Posted on 1998-09-03
2
2,036 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
count8 challlenge 13 86
strDist challenge 35 84
solarwind tftp server 2 32
starter POM and spring-boot-starter,  spring-boot-web 2 14
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

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

21 Experts available now in Live!

Get 1:1 Help Now