[Top][All Lists]

[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:
   at javax.swing.filechooser.FileSystemView.getFiles (FileSystemView.java:143)
   at javax.swing.plaf.basic.BasicDirectoryModel.validateFileCache
   at javax.swing.plaf.basic.BasicFileChooserUI.rescanCurrentDirectory
   at javax.swing.plaf.basic.BasicFileChooserUI$12.propertyChange
   at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange
   at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange
   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)

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);

                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.



reply via email to

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