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

1.4 REGRESSION: JFileChooser with FileSystemView causes floppy access

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Won't Fix
    • Affects Version/s: 1.4.1
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description



      Name: jk109818 Date: 09/16/2002


      FULL PRODUCT VERSION :
      java version "1.4.1-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
      Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)

      FULL OPERATING SYSTEM VERSION :

      Microsoft Windows XP [Version 5.1.2600]


      A DESCRIPTION OF THE PROBLEM :
      When constructing a JFileChooser by passing a
      FileSystemView, the floppy drive is accessed which
      degrades the performance of the file chooser. The same
      thing occurs each time the directory is changed.

      This does not happen if the default JFileChooser
      constructor is used, or with 1.3.1 jdk's. (it does happen
      with 1.4.0)

      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Construct a JFileChooser by passing in a FileSystemView
      2. Show the file chooser (notice that the floppy drive is
      accessed so the chooser takes a while to appear)
      3. Change the directory using the "go to parent" button -
      notice the floppy is accessed which degrades performance.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I do not expect the floppy to be accessed because I pass
      in a FileSystemView, especially the simple one above. It
      didn't happen in earlier releases.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Quickly hacked code:

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.util.*;
      import javax.swing.filechooser.*;
      import java.io.*;

      public class FileSystemViewTest extends JFrame {

         JButton showFileChooserButton;
         JButton exitButton;
         
         public FileSystemViewTest() throws AWTException {
            super("File System View Test");
            getContentPane().setLayout(new FlowLayout());
            
            showFileChooserButton = new JButton("Show File Chooser");
            showFileChooserButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      showFileChooser();
              }
            });

            exitButton = new JButton("Exit");
            exitButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
                   System.exit(0);
              }
            });
            
            getContentPane().add(showFileChooserButton);
            getContentPane().add(exitButton);

            addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent e) {
                  System.exit(0);
               }
            });
            
         }

      public void showFileChooser() {
          JFileChooser jc = new JFileChooser(new MyFileSystemView());
      // JFileChooser jc = new JFileChooser(); if you use this constructor
      // instead, no floppy access
          jc.showOpenDialog(this);
      }
                 

         public static void main(String[] args) throws AWTException {
            FileSystemViewTest frame= new FileSystemViewTest();
            frame.pack();
            frame.setVisible(true);
         }

      public class MyFileSystemView extends FileSystemView {

         private FileSystemView fileSystem = getFileSystemView();

         public MyFileSystemView() {
             super();
         }

         public File[] getRoots() {
             return fileSystem.getRoots();
         }

         public boolean isHiddenFile (File file) {
      return fileSystem.isHiddenFile(file);
         }

         public boolean isRoot (File file) {
      return fileSystem.isRoot(file);
         }

         public File createNewFolder (File parentDirectory) throws IOException {
      return fileSystem.createNewFolder(parentDirectory);
         }

      }

      }
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      None.

      Impact on user below: No impact, doesn't stop us from
      developing, but the performance of the file chooser is
      terrible if you want to provide your own FileSystemView.

      Release Regression From : 1.3.1
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 164471)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              leifs Leif Samuelsson (Inactive)
              Reporter:
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: