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

JFileChooser.setAcceptAllFileFilterUsed(false) displays empty "Files of Type"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 7
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.7.0_04"
      Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
      Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux quattro 3.3.3 #1 SMP Mon Apr 23 07:58:23 CEST 2012 x86_64 Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz GenuineIntel GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      When JFileChooser.setAcceptAllFileFilterUsed(false) is used and a single file filter was specified the "Files of Type" combo box is initially empty, i.e. there is no file type entry at all. This is a regression compared to Java 6. With Java 6 the file type specified by the file filter is displayed there as the initial selection.
      Not displaying anything even though there is an entry available (the only one actually selectable by the user) appears to be a bug.


      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the sample program attached to this report and run it with Java 7 and Java 6. Note that the initial content of the JFileChooser's "Files of Type" field differs depending on the Java version being used.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      After starting the sample application the "Files of Type" box should contain the "XML Files" string, as this is the only entry that is available as a selection for this box.
      ACTUAL -
      The "Files of Type" box is empty. The user has to select "XML Files" explicitly, even though this is the only available selection.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JFrame;
      import javax.swing.JFileChooser;
      import javax.swing.filechooser.FileNameExtensionFilter;

      public class Test extends JFrame {
        Test() {
          JFileChooser chooser = new JFileChooser();
          chooser.addChoosableFileFilter(new FileNameExtensionFilter("XML Files", "xml"));
          chooser.setAcceptAllFileFilterUsed(false);
          chooser.showOpenDialog(this);
        }

        public static void main(String[] args) {
          new Test();
        }
      }

      ---------- END SOURCE ----------

            rupashka Pavel Porvatov (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: