Solved

Select a directory in a FileDialog?

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What browser will run Java? 7 170
Java Inheritance super keyword use 8 71
JVM error from eclipse 1 25
Selenium findElement(By.classname  identifier 15 32
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

737 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