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

GTK: JFileChooser directory list is incorrect when an empty directory is passed

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b32
    • CPU:
      x86
    • OS:
      windows_xp

      Description



      Name: ibR10256 Date: 11/25/2003



      If an empty directory (it must not contain files and subdirectories)
      is passed to the JFileChooser's constructor the first item in the
      file chooser directory list is "null". When double-clicking "null"
      NullPointerException is thrown.

      The same happens when the directory is not really empty but a
      FileFilter is used which filters out all the files located in the
      directory.

      This doesn't happen if the the same empty directory is browsed in the
      directory list starting from another directory.

      Here's a test case:

      ---------------------------------------------
      import javax.swing.*;
      import java.awt.*;

      public class GTKFileChooserFilter {
          public static void main(String[] args) {
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              try {
                  UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
              } catch (Exception e) {
                  e.printStackTrace();
              }

              // The directory used in the constructor must be empty
              JFileChooser fc = new JFileChooser("/home/iib/empty");
              frame.getContentPane().add(fc);
              
              frame.pack();
              frame.setVisible(true);
          }
      }
      ---------------------------------------------

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naasunw Naa Naa (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: