本文介绍了在Mac上用于目录的JFileChooser:如何使其不烂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac上,仅目录"模式下的JFileChooser存在两个严重的严重问题:

1)您不能使用它创建目录

2)您不能切换驱动器

对于我的安装程序而言,这是一个很大的问题.据我所知,Apple无法解决此问题,您甚至无法激活非本地目录选择器...因此,唯一的选择是找到一个免费的/开源的纯Java替换小部件. >

有人知道吗?

解决方案

如何使用java.awt.FileDialog?它显示了一个本机文件选择器,并允许创建新文件夹.

public static void main(String[] args) throws UnsupportedLookAndFeelException {
    JFrame frame = new JFrame();
    System.setProperty("apple.awt.fileDialogForDirectories", "true");
    FileDialog d = new FileDialog(frame);
    d.setVisible(true);
}

The JFileChooser in "directories only" mode on the Mac has two serious, crippling problems:

1) You cannot create directories with it

2) You cannot switch drives

This is rather a huge problem for my installer app. As far as I can tell, Apple provides no way around this problem, you can't even activate the non-native directory chooser ... so the only alternative is to find a free/open source pure-Java replacement widget.

Does anybody know of one?

解决方案

What about using java.awt.FileDialog? It shows a native file chooser and allows creating new folders.

public static void main(String[] args) throws UnsupportedLookAndFeelException {
    JFrame frame = new JFrame();
    System.setProperty("apple.awt.fileDialogForDirectories", "true");
    FileDialog d = new FileDialog(frame);
    d.setVisible(true);
}

这篇关于在Mac上用于目录的JFileChooser:如何使其不烂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 12:42