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

[macosx] All files filter can't be selected in JFileChooser

    XMLWordPrintable

Details

    • b120
    • x86
    • os_x

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_73"
      Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.9.5

      A DESCRIPTION OF THE PROBLEM :
      The All files file filter can't be selected in the Open dialog or Save dialog on Mac OS X.

      This means that for all intents and purposes, JFileChooser is broken on the Mac in Java 8, which also makes it impossible for us to use Java 8. This is a critical regression from Java 7 that hurts development of our Java-based product.

      REGRESSION. Last worked in version 7u76

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.7.0_67"
      Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
      Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JFileChooser with one FileFilter, and set acceptAllFileFilterUsed to true, then create an Open dialog using the file chooser.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The user is able to select the All files file filter.
      ACTUAL -
      The user cannot select the All files file filter.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JFileChooser;
      import javax.swing.SwingUtilities;
      import javax.swing.filechooser.FileFilter;
      import java.io.File;

      public class JFileChooserBug {

          public static void main(String[] args) {
              Runnable runnable = new Runnable() {
                  public void run() {
                      JFileChooser chooser = new JFileChooser(new File("Users/manne"));
                      chooser.setAcceptAllFileFilterUsed(true);
                      chooser.setDialogType(JFileChooser.OPEN_DIALOG);
                      FileFilter txtFilter = new FileFilter() {
                          @Override
                          public boolean accept(File f) {
                              return f.getName().endsWith(".txt");
                          }

                          @Override
                          public String getDescription() {
                              return "Text files";
                          }
                      };
                      chooser.addChoosableFileFilter(txtFilter);
                      chooser.setFileFilter(txtFilter);
                      chooser.showOpenDialog(null);
                  }
              };
              SwingUtilities.invokeLater(runnable);
          }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              alexsch Alexandr Scherbatiy
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: