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

JFileChooser: Cannot navigate to file filters via first letter of filter

XMLWordPrintable

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      Given a JFileChooser with multiple file filters, the desired file filter is not selectable via it's first letter.

      The JavaDoc for combo-box (JComboBox);

      http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/doc-files/Key-Index.html#JComboBox

        states that items in the combo-box can be navigated to by typing the first letter of the item - the "Files of Type" combo-box does not honour this.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile and run the supplied source code.
      2. When the JFileChooser appears, click the drop-down for the "Files of Type" component.
      3. Try to navigate to the file filter item "Project Files (*.prj)" by typing the letter "P" (or "p").
      4. There is *no* navigation support as described in the JavaDoc for combo-box.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected navigation to work, per JavaDoc.
      ACTUAL -
      No navigation to file filter items in the drop-down.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.io.File;

      import javax.swing.JFileChooser;
      import javax.swing.SwingUtilities;

      public class TestDesktopShortcutBug {

      public static void main(String[] args) {
      System.out.println("JRE version: " + System.getProperty("java.version"));
      JFileChooser fileChooser = new JFileChooser();

      fileChooser.addChoosableFileFilter(new MyFilter1());
      fileChooser.addChoosableFileFilter(new MyFilter2());
      fileChooser.addChoosableFileFilter(new MyFilter3());
      fileChooser.showOpenDialog(null);
      }

      }

      class MyFilter1 extends javax.swing.filechooser.FileFilter {
      @Override
          public boolean accept(File file) {
              String filename = file.getName();
              return filename.endsWith(".stx");
          }
          public String getDescription() {
              return "Status Files (*.stx)";
          }
      }
      class MyFilter2 extends javax.swing.filechooser.FileFilter {
      @Override
          public boolean accept(File file) {
              String filename = file.getName();
              return filename.endsWith(".prj");
          }
          public String getDescription() {
              return "Project Files (*.prj)";
          }
      }
      class MyFilter3 extends javax.swing.filechooser.FileFilter {
      @Override
          public boolean accept(File file) {
              String filename = file.getName();
              return filename.endsWith(".sty");
          }
          public String getDescription() {
              return "Report Files (*.rep)";
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      There is no workaround.

            tr Tejesh R
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: