JDK-4470177 : JFileChooser constructor behaves erratically on "." as argument
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2001-06-14
  • Updated: 2002-03-21
  • Resolved: 2002-03-21
Related Reports
Relates :  
Description

Name: bsC130419			Date: 06/14/2001


c:\>java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

In JDK 1.2 and JDK 1.3, you could do the following

   new JFileChooser(".")

which brought up a JFileChooser in the currentl directory.  In JDK 1.4, the
JFileChooser fails in an erratic manner when "." is used in the constructor.

If "." is used, the JFileChooser opens up, with the current directory displayed
in the Combo Box at the top, but no files are displayed.  Re-selecting the exact
same directory in the combo box causes the files in the directory to then be
displayed!

If you try to move up one directory *before* you reselect the current directory
(as described above) the following exception is thrown.

FileSystemView.getShellFolder: f=.
java.lang.InternalError: Could not parse file path
	at sun.awt.shell.Win32ShellFolder.initFile(Native Method)
	at sun.awt.shell.Win32ShellFolder.<init>(Win32ShellFolder.java:175)
	at sun.awt.shell.Win32ShellFolder.<init>(Win32ShellFolder.java:182)
	at
sun.awt.shell.Win32ShellFolderManager.createShellFolder(Win32ShellFolderManager.java:34)
	at sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:194)
	at javax.swing.filechooser.FileSystemView.getShellFolder(FileSystemView.java:447)
	at javax.swing.filechooser.FileSystemView.getParentDirectory(FileSystemView.java:423)
	at javax.swing.JFileChooser.changeToParentDirectory(JFileChooser.java:545)
	at
javax.swing.plaf.basic.BasicFileChooserUI$ChangeToParentDirectoryAction.actionPerformed(BasicFileChooserUI.java:658)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1722)
	at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1775)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:414)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:253)
	at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:261)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:230)
	at java.awt.Component.processMouseEvent(Component.java:4906)
	at java.awt.Component.processEvent(Component.java:4732)
	at java.awt.Container.processEvent(Container.java:1337)
	at java.awt.Component.dispatchEventImpl(Component.java:3476)
	at java.awt.Container.dispatchEventImpl(Container.java:1399)
	at java.awt.Component.dispatchEvent(Component.java:3343)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3302)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3014)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2967)
	at java.awt.Container.dispatchEventImpl(Container.java:1373)
	at java.awt.Window.dispatchEventImpl(Window.java:1459)
	at java.awt.Component.dispatchEvent(Component.java:3343)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:439)
	at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:131)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
java.lang.NullPointerException
	at javax.swing.filechooser.FileSystemView.getParentDirectory(FileSystemView.java:424)
	at javax.swing.JFileChooser.changeToParentDirectory(JFileChooser.java:545)
	at
javax.swing.plaf.basic.BasicFileChooserUI$ChangeToParentDirectoryAction.actionPerformed(BasicFileChooserUI.java:658)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1722)
	at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1775)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:414)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:253)
	at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:261)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:230)
	at java.awt.Component.processMouseEvent(Component.java:4906)
	at java.awt.Component.processEvent(Component.java:4732)
	at java.awt.Container.processEvent(Container.java:1337)
	at java.awt.Component.dispatchEventImpl(Component.java:3476)
	at java.awt.Container.dispatchEventImpl(Container.java:1399)
	at java.awt.Component.dispatchEvent(Component.java:3343)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3302)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3014)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2967)
	at java.awt.Container.dispatchEventImpl(Container.java:1373)
	at java.awt.Window.dispatchEventImpl(Window.java:1459)
	at java.awt.Component.dispatchEvent(Component.java:3343)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:439)
	at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:131)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

If you had reselected the current directory, before you tried to move up one
directory, no exception is thrown and everything works fine.

This is not a usage problem!  This is buggy behavior!  "." is a valid pathname
on windows/solaris platforms, and the behavior is not consistent in the
JFileChooser.

Robert Evans
(Review ID: 126618) 
======================================================================

Comments
EVALUATION Name: keR10081 Date: 03/21/2002 In fact, this bug has stopped being reproducible somewhere between build 65 and build 70. Closing as not reproducible. ###@###.### ======================================================================
15-09-2004

WORK AROUND Name: bsC130419 Date: 06/14/2001 Construct a path using getClass().getResource().... ======================================================================
15-09-2004