Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8025503

[macosx] FileDialog allows file selection with apple.awt.fileDialogForDirectories = true

XMLWordPrintable

    • b112
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0-ea"
      Java(TM) SE Runtime Environment (build 1.8.0-ea-b103)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b45, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OSX 10.8.4

      A DESCRIPTION OF THE PROBLEM :
      we have been using the following approach to show a native
      file dialog to choose a directory:

      FileDialog fileDialog = .....;

      fileDialog.setMode(FileDialog.LOAD);∫
              try {
                  System.setProperty("apple.awt.fileDialogForDirectories", "true");
                  fileDialog.setVisible(true);
              } finally {
                  System.setProperty("apple.awt.fileDialogForDirectories", "false");
              }

      Now I noticed with build 103 that this allows me to select files as well. Starting the same application with Apple's JDK 6 behaves as expected (files cannot be selected).

      A guess (based on explanations by Oracle's Alexander Scherbatiy):

      In that case NSOpenPanel.setCanChooseDirectories ist set to true but NSOpenPanel.setCanChooseFiles is not set to false as it should be.

      REGRESSION. Last worked in version 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      see above

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      FileDialog should allow selection of Directories but not allow selection of files
      ACTUAL -
      FileDialog allows selection of files and directories

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      see above
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use a native Dialog via JNI

            pchelko Petr Pchelko (Inactive)
            rcalnan Roger Calnan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: