开发者

JFileChooser and NTFS JunctionPoints / Symlinks?

The JFileChooser in Swing (Java 1.6.0_u25) doesn't seem to know how to deal with NTFS Junction Points or Symbolic Links.

The file chooser has no special handling:

int rv = mainfileChooser.showOpenDialog(parentFrame)

When using this on a Windows 7 box, the special folders under My Documents (My Pictures, My Videos, My Music) can't be entered - the user clicks on them, but nothing happens and they can't be selected. After some experimentation, the same thing happens with any SymLink or Junction Point (both pre-generated by the OS and manually created.)

.lnk Shortcuts to directories work fine.

Is there a way to fix this and let my users save images in "My Pictur开发者_JS百科es"?


The problem with those special types is that they are not cross-platform, so that's the reason JFileChooser doesn't support them.

You may want to use the native XFileDialog. Didn't use it by myself, but it seems relevant for you. Keep in mind that it is native and will not be portable to Linux / OSX.


Special folders work for me at least in the system look and feel.

try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e1) {
} catch (InstantiationException e1) {
} catch (IllegalAccessException e1) {
} catch (UnsupportedLookAndFeelException e1) {
}


By an amazing coincidence, Java 1.6u27 just shipped, and includes a fix for this very issue!

Release Notes: http://www.oracle.com/technetwork/java/javase/2col/6u27bugfixes-444150.html

Bug Writeup: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7012783

The bug discussion revolves around DFS links, rather than Junction points, but I believe the issues are the same, and testing this locally all the wacky behavior has gone away and I can save to My Pictures (and friends) just fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜