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

JFileChooser DIRECTORIES_ONLY is broken

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.6
    • client-libs



      Name: diC59631 Date: 07/16/98


      There seems to be a race condition in the JFilechooser.

      When the DIRECTORIES_ONLY option is set,
      the JFileChooser seems to randomly filter using
      it when first bringing up the dialog. That is, sometimes
      only directories are shown in the file list, other times
      both directories and files are listed.

      I used the following code:

      import java.awt.*;
      import java.awt.event.*;
      import java.io.*;
      import com.sun.java.swing.*;
      import com.sun.java.swing.preview.*;
      import com.sun.java.swing.preview.filechooser.*;


      public class FCTest {
          Frame f;
          public FCTest()
          {
              f = new Frame();
              Button b = new Button();
              f.add(b);
              b.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      JFileChooser filechooser = new JFileChooser();
                      filechooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                      filechooser.showDialog(new Frame(), "Choose Directory");
                  }
              });
              f.setSize(100, 100);
              f.setVisible(true);
              
          }
          public static void main(String[] args)
          {
              FCTest t = new FCTest();
          }
      }


      This is running under NT4.0SP3 with JDK 1.1.5 and JDK 1.1.6
      with and without the jit.
      (Review ID: 35171)
      ======================================================================

            jeff Jeff Dinkins
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: