loganhuskins
loganhuskins

Reputation: 1469

JFileChooser select just directories

I am using JFileChooser to allow the user of my application to select a directory for file storage. Per the documentation and other StackOverflow questions I have researched I have added this bit of code:

fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

Doing this does return the directory that I need, but to select that directory you have to select a file in that directory. If the directory is empty you have to create a file in it to select. My question is, is there a way to display only directories and to be able to select from those directories even if they have sub-directories?

Upvotes: 1

Views: 3921

Answers (1)

loganhuskins
loganhuskins

Reputation: 1469

I had AcceptAllFileFilterUsed set to false, which was causing this issue.

Upvotes: 2

Related Questions