bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/23012] swing: JFileChooser("/thisdoesnotexist") throws Nu


From: gcc-bugzilla at gcc dot gnu dot org
Subject: [Bug classpath/23012] swing: JFileChooser("/thisdoesnotexist") throws NullPointerException
Date: 8 Sep 2010 18:04:49 -0000

Steps to reproduce:
1. Compile and run the attached testcase.

Expected results:
1. filechooser's "Open" dialog shows user's home directory.

Actual results:
1. No window is shown and program throws the following exception:
java.lang.NullPointerException
   at javax.swing.filechooser.FileSystemView.getFiles (FileSystemView.java:143)
   at javax.swing.plaf.basic.BasicDirectoryModel.validateFileCache
(BasicDirectoryModel.java:292)
   at javax.swing.plaf.basic.BasicFileChooserUI.rescanCurrentDirectory
(BasicFileChooserUI.java:1639)
   at javax.swing.plaf.basic.BasicFileChooserUI$12.propertyChange
(BasicFileChooserUI.java:1583)
   at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange
(SwingPropertyChangeSupport.java:223)
   at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange
(SwingPropertyChangeSupport.java:196)
   at javax.swing.JComponent.firePropertyChange (JComponent.java:721)
   at javax.swing.JFileChooser.setCurrentDirectory (JFileChooser.java:405)
   at javax.swing.JFileChooser.<init> (JFileChooser.java:243)
   at testcase.<init> (testcase.java:8)
   at testcase.main (testcase.java:5)

Testcase:
import javax.swing.*;
import java.awt.*;
public class testcase extends JFrame {
        public static void main(String[] args) {
                new testcase();
        }
        public testcase() {
                new JFileChooser("/thisdoesnotexist").showOpenDialog(this);
        }
}


------- Comment #1 from from-classpath at savannah dot gnu dot org  2005-07-06 
13:20 -------
This is the bugfix:

change in javax.swing.filechooser.FileSystemView
the following method:

public File createFileObject(String path)
  {
     return new File(path);
  }

to this one:

public File createFileObject(String path)
  {
        File temp = new File(path);

        if(temp.isDirectory())
                return temp;

    return null;
  }


The patch is under 10 lines, so you can take it. And its trivial


------- Comment #2 from from-classpath at savannah dot gnu dot org  2005-07-08 
15:07 -------
Fixed as of July 8, 2005.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23012




reply via email to

[Prev in Thread] Current Thread [Next in Thread]