• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting a filename filter in Filedialog

 
krish chandru
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create a File dialog that shows only the available directories in the drive and not any files. Can i achieve this using the File Name filter ? if yes, Please let me know how i can do this !
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about

boolean isDirectory()
Tests whether the file denoted by this abstract pathname is a directory.

in the File class?
 
krish chandru
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes , using isDirectory i can very well confirm a directory but i need to set a filter in the filedialog itself so that i can restrict the user to the level of directories. The user can select only the directory and cant descend to the file structure level.
whenever a user clicks the browse button he should be shown only the available directories and not the files !
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by krish chandru:
Yes , using isDirectory i can very well confirm a directory but i need to set a filter in the filedialog itself [...]
What is your filter but an object that confirms directories? Have a look at the FileFilter class, it'll take you all of five minutes to do.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic