-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: nkR10003 Date: 11/17/2000
JFileChooser.setSelectedFile(File) sometimes throws NullPointerException
Example below demonstrates this problem:
------------------example--------------------
//test.java
import javax.swing.*;
import java.io.*;
public class test {
public static void main(String[] args) {
File wdir = new File("/etc");
for (int i=0; i<1000; i++) {
try {
JFileChooser fileChooser = new JFileChooser(wdir);
File pswd = new File(wdir, "passwd");
fileChooser.setSelectedFile(pswd);
if (!fileChooser.getSelectedFile().equals(pswd)) {
System.out.println("Method setSelectedFile() works wrong");
System.out.println("Test failed");
System.exit(0);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Test failed");
System.exit(0);
}
}
System.out.println("Test passed OK");
System.exit(0);
}
}
----------------output:----------------------
java.lang.NullPointerException
at javax.swing.JLabel.setIcon(JLabel.java:377)
at javax.swing.plaf.metal.MetalFileChooserUI$FileRenderer.getListCellRendererComponent(MetalFileChooserUI.java:637)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:772)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:722)
at javax.swing.plaf.basic.BasicListUI.getCellBounds(BasicListUI.java:598)
at javax.swing.JList.getCellBounds(JList.java:845)
at javax.swing.JList.ensureIndexIsVisible(JList.java:758)
at javax.swing.plaf.metal.MetalFileChooserUI.setFileSelected(MetalFileChooserUI.java:709)
at javax.swing.plaf.metal.MetalFileChooserUI.doSelectedFileChanged(MetalFileChooserUI.java:734)
at javax.swing.plaf.metal.MetalFileChooserUI.access$800(MetalFileChooserUI.java:31)
at javax.swing.plaf.metal.MetalFileChooserUI$8.propertyChange(MetalFileChooserUI.java:847)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:162)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:130)
at javax.swing.JComponent.firePropertyChange(JComponent.java:3438)
at javax.swing.JFileChooser.setSelectedFile(JFileChooser.java:417)
at test.main(test.java:10)
Test failed
---------------------------------------------
To reproduce this failure run the test example from this report on
a multiprocessor machine.
Also, you can reproduce this by running the JCK test (see Justification
field (*)) in JavaTest in single JVM configuration on any machine.
======================================================================
- duplicates
-
JDK-4997165 REGRESSION:JFileChooser throws NPE
- Closed