aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JFileChooser: setSelectedFile() hangs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser: setSelectedFile() hangs" Watch "JFileChooser: setSelectedFile() hangs" New topic
Author

JFileChooser: setSelectedFile() hangs

Guido Sautter
Ranch Hand

Joined: Dec 22, 2004
Posts: 142
Hi Ranchers,

I have a problem with JFileChooser under Windows XP (JVM version doesn't seem to matter, tried 1.4.2 and above):

The setSelectedFile() method hangs up inside JFileChooser, but only if the file previously selected is located in the user's Desktop. If the previous file resides in other sub folders of 'Documents and Settings/<userName>/...', it works OK, so it's probably not a matter of the spaces in the path.

Under Windows 2000, it works fine.

Does anyone have similar experiences, maybe even a solution or workaround? Google didn't produce any helpful results.

Thanks in advance,
Guido
G Estes
Ranch Hand

Joined: Oct 22, 2002
Posts: 62
Can you post some code as to how you are implementing the file chooser?
Guido Sautter
Ranch Hand

Joined: Dec 22, 2004
Posts: 142
The code belong to a File IO component of the software I write. Here the fields:
- lastSaveFile is an instance filed holding the file last saved to
- model is a method argument, basically providing the format a document was last saved in (XML, txt, etc.)
- selectedFormat is the JFileChooser FileFilter matching the saving format
- fileKeeper is an instance field, ensuring that the file name in the JFileChooserUI has the appropriate extension if the saving format changes

The line that hangs is fileChooser.setSelectedFile(target);



JConsole shows that the invocation of setSelectedFile() hangs somewhere deep inside Swings PLaF, in FileView.ensureFileVisible(), with some Win32 classes in the stack trace. The final blocking occurs on Unsafe.wait().

Thanks for any ideas.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFileChooser: setSelectedFile() hangs