I tried to create a JFileChooser but I don't understand how to set it to show directories only.
+3
A:
JFileChooser f = new JFileChooser();
f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if(f.showOpenDialog(parent)== JFileChooser.APPROVE_OPTION) {
File result = f.getSelectedFile();
} else {
...
}
Michael Borgwardt
2010-06-09 13:46:17
theseion
2010-06-09 13:48:00
A:
Have look at this code snippet - that sounds promising.
The most intersting line is:
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
Andreas_D
2010-06-09 13:47:11
A:
Apart from what Michael already suggested you might take a look at JIDE OSS, a free Swing components library, which amongst many other goodies provides a much nicer folder chooser component(FolderChooser).
Bozhidar Batsov
2010-06-09 13:49:05