Java(TM) SE Runtime Environment (build 1.6.0_29-b11-397-11M3521)
Steps to reproduce:
- Run the code below:
----------------------------
import java.io.*;
import javax.swing.*;
public class FileChooserDirTest {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File[] files = chooser.getSelectedFiles();
for(File file: files){
System.out.println("Selected file: " + file);
}
}
}
});
}
}
----------------------------
- Select both files and directories
The directories are not deselected