JDK-8000969 : [macosx] Directories are not deselected when JFileChooser has FILES_ONLY selection mode
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-10-16
  • Updated: 2014-10-13
  • Resolved: 2012-10-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b63Fixed
Related Reports
Relates :  
Description
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
Comments
The files are disabled in the DIRECTORIES_ONLY JFileChooser selection mode. So it is not possible to select them. In the FILES_ONLY selection mode the directories should be enabled. It needs to deselect the selected directories in the property change listener.
16-10-2012