Skip to main content

JFileChooser on Windows Vista

Posted by loneid on March 30, 2007 at 11:01 AM PDT

JFileChooser on Windows Vista

Recently, Microsoft released Windows Vista, their new operating system, and almost simultaneously Sun released Java 6. Unfortunately, it turns out that some of the features in JFileChooser do not work properly on Vista. This article discusses these problems and proposes solutions.

The good news is that the primary functionality of JFileChooser is not broken. You can still browse for files and directories, observe their details and choose those you need. However, when performing these activities in certain folders, some inconveniences may arise. Let's have a look at them, one by one.

1. Public and directories traversability


This issue is best reproduced with the Windows look-and-feel, although it concerns the Java look-and-feel as well (please see the GUIDs issue below). If you open a JFileChooser's dialog and navigate to the Desktop, you'll see, among others, two special folders there: Public and , where is the name of the user currently logged on. Unfortunately, these folders cannot be opened by double-clicking them from the desktop. But there is a workaround, and you can access them at their actual location in the file system, which is usually C:\Users\Public and C:\Users\.

2. GUIDs instead of names


The handling of these special folders has another flaw when running
applications with the Java look-and-feel. Not only will you be unable to enter the Public and folders from the Desktop, but you will also see GUIDs instead of the folder names (GUIDs are strings like ::{4336A54D-038B-4685-AB02-99BB52D3FB8B} and are used by Windows internally). Fortunately, the workaround suggested for the previous issue still works here as well.

3. Recent folder is empty


The name of this issue says it all. Regardless of how you try to browse the Recent special folder, its contents are not shown. This happens in both Java and Windows look-and-feels, and there are no known workarounds.

Why have these issues arisen? The root cause is that Vista differs from older Windows versions not only visually. Microsoft modified their Shell API functions to be more tightly coupled with COM, and some interface methods returned slightly different values than before, so the adaptation and testing took significant time. Thankfully, this task is almost completed and we intend to provide a fixed JFileChooser with Java 6 update 2.

Related Topics >>