JDK-6210674 : FileChooser fails to load custom harddrive icon and gets NullPointerException
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2004-12-20
  • Updated: 2011-05-17
  • Resolved: 2011-05-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b27Fixed
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Maxtor E14G300 300Gb 7200rpm Onetouch II 16Mb External USB2.0/Firewire

A DESCRIPTION OF THE PROBLEM :
I own an external firewire harddrive that  use a custom icon. When I create a JFileChooser using the Windows system L&F I get a NullPointerException.

Note, code below will return the correct icon so there is a bug in the file chooser code.

FileSystemView fsv = FileSystemView.getFileSystemView();
fsv.getSystemIcon(new File("i:/"));


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a java application, set the L&F to system, create a JFileChooser. Prerequisits is of course a external harddrive with custom icon...


ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
        at javax.swing.ImageIcon.<init>(Unknown Source)
        at javax.swing.ImageIcon.<init>(Unknown Source)
        at sun.swing.WindowsPlacesBar.<init>(Unknown Source)
        at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(Unknown Source)

        at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(Unknown Source)
        at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
        at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Unknown Source)
        at javax.swing.JComponent.setUI(Unknown Source)
        at javax.swing.JFileChooser.updateUI(Unknown Source)
        at javax.swing.JFileChooser.setup(Unknown Source)
        at javax.swing.JFileChooser.<init>(Unknown Source)
        at javax.swing.JFileChooser.<init>(Unknown Source)
        at Test.main(Test.java:12)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

public class Test
{
	public static void main(String ... args)
	{
		try
		{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

			JFileChooser chooser = new JFileChooser();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Do not use system L&F in windows.
###@###.### 2004-12-20 17:12:59 GMT

Comments
EVALUATION WindowsPlacesBar should use default icon for folders that doesn't have own icon
29-04-2008

EVALUATION Will investigate for next release. ###@###.### 2005-04-18 22:33:45 GMT
18-04-2005