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

can't set custom file description in JFileChooser details view

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP Professional Version 2002 Service Pack2
      Microsoft Windows 2000 5.00.2195 Service Pack 4

      A DESCRIPTION OF THE PROBLEM :
      I have been using a custom FileSystemView with JFileChooser to generate custom file descriptions for certain types of files. This is an integral feature of my application and has been working perfectly under JRE v1.5.x for a long time. But when I made the move to JRE v1.6 I found this function is broke. My custom getSystemTypeDescription method in MyFileSystemView is ignored. Also, my custom type header text is ignored. The type header text is set by :

      UIManager.put("FileChooser.fileTypeHeaderText", "My Description");


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a new class MyFileSystemView that extends FileSystemView. Generate a new getSystemTypeDescription method to return the custom file type description. Delegate all other methods to FileSystemView.getFileSystemView(). Change the file type header text to the custom name. Create a new JFileChooser and set its FileSystemView to the MyFileSystemView. Then call showDialog on the JFileChooser and switch to the details view. Under JRE v1.5.x the file type header will be set to the custom name, and the type descriptions will be set to the custom descriptions. Under JRE v1.6.0, the standard system file view descriptions are used.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect JRE v1.6.0 to work the same as JRE v1.5.x.
      ACTUAL -
      The JRE v1.5 file chooser dialog can be viewed here:

      http://ionetrics.com/fileChooser1.5.png

      The JRE v1.6 file chooser dialog can be viewed here:

      http://ionetrics.com/fileChooser1.6.png

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*-------------------------------------------------------------------------*/
      /**
       * FileChooserBug.java
       */

      import javax.swing.*;
      import static javax.swing.JFileChooser.*;

      public class FileChooserBug
        {
        public static void main(String[] args)
          {
          try
            {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            }
          catch (Exception e)
            {
            System.err.println("Error loading L&F: " + e);
            }

          JFileChooser chooser = new JFileChooser();
          chooser.setDialogType(OPEN_DIALOG);
          chooser.setFileSystemView(new MyFileSystemView());
          chooser.showDialog(null, null);
          }
        } //end of class FileChooserBug
      /*-------------------------------------------------------------------------*/

      /*-------------------------------------------------------------------------*/
      /**
       * MyFileSystemView.java
       */

      import javax.swing.filechooser.FileSystemView;
      import javax.swing.*;
      import java.io.File;
      import java.io.IOException;

      public class MyFileSystemView extends FileSystemView
        {
        private static FileSystemView _systemFileSystemView = FileSystemView.getFileSystemView();

        public MyFileSystemView()
          {
          super();
          UIManager.put("FileChooser.fileTypeHeaderText", "My Description");
          }
        public File createNewFolder(File containingDir) throws IOException
          {
          return _systemFileSystemView.createNewFolder(containingDir);
          }
        public File createFileObject(File dir, String filename)
          {
          return _systemFileSystemView.createFileObject(dir, filename);
          }
        public File createFileObject(String path)
          {
          return _systemFileSystemView.createFileObject(path);
          }
        public File getChild(File parent, String fileName)
          {
          return _systemFileSystemView.getChild(parent, fileName);
          }
        public File getDefaultDirectory()
          {
          return _systemFileSystemView.getDefaultDirectory();
          }
        public File[] getFiles(File dir, boolean useFileHiding)
          {
          return _systemFileSystemView.getFiles(dir, useFileHiding);
          }
        public File getHomeDirectory()
          {
          return _systemFileSystemView.getHomeDirectory();
          }
        public File getParentDirectory(File dir)
          {
          return _systemFileSystemView.getParentDirectory(dir);
          }
        public File[] getRoots()
          {
          return _systemFileSystemView.getRoots();
          }
        public String getSystemDisplayName(File f)
          {
          return _systemFileSystemView.getSystemDisplayName(f);
          }
        public Icon getSystemIcon(File f)
          {
          return _systemFileSystemView.getSystemIcon(f);
          }
        public String getSystemTypeDescription(File f)
          {
          return "my description";
          }
        public boolean isComputerNode(File dir)
          {
          return _systemFileSystemView.isComputerNode(dir);
          }
        public boolean isDrive(File dir)
          {
          return _systemFileSystemView.isDrive(dir);
          }
        public boolean isFileSystem(File f)
          {
          return _systemFileSystemView.isFileSystem(f);
          }
        public boolean isFileSystemRoot(File dir)
          {
          return _systemFileSystemView.isFileSystemRoot(dir);
          }
        public boolean isFloppyDrive(File dir)
          {
          return _systemFileSystemView.isFloppyDrive(dir);
          }
        public boolean isHiddenFile(File f)
          {
          return _systemFileSystemView.isHiddenFile(f);
          }
        public boolean isParent(File folder, File file)
          {
          return _systemFileSystemView.isParent(folder, file);
          }
        public boolean isRoot(File f)
          {
          return _systemFileSystemView.isRoot(f);
          }
        public Boolean isTraversable(File f)
          {
          return _systemFileSystemView.isTraversable(f);
          }
        } //end of class MyFileSystemView
      ---------- END SOURCE ----------

      Release Regression From : 5.0
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            Unassigned Unassigned
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: