Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser problem

 
Erwin Bredford
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi got this problem!
trying to select ONLY directories from a filechooser
this is the code


Now the problem is that i would have to choose a file and i don't want to choose only directories .
does any one know how to get around this problem.
 
Stefan Willi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at this post.

There are examples, to select only directories and both directories and files.

stefan
 
Erwin Bredford
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry let me correct that the file directory force me to choose files but i want to choose directories.
i need a way round it.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just have to love the API Docs. They almost always seem to have the answers.

setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!