• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser  RSS feed

 
Peter Phung
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to use JFilechooser to select a directory. I'm using the method getCurrentDirectory(). However, jfilechooser seems to only return the directory when i select a file first.
Can anybody tell me how i can return the directory without first selecting a file?
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the getSelectedFile method instead. It will return a directory if that is what is selected. You can also use setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) to ensure that only directories may be selected.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!