我正在运行一个分析数据的Java程序,我写的。当我尝试加载数据文件时,JFileChooser将照常打开,但我无法双击该文件夹来更改工作目录。任何人遇到这个问题,是否有解决方法?我不确定它是java,eclipse,mac还是组合问题。JFileChooser无法识别文件夹,无法更改目录
我运行在Mac 10.12.6(塞拉利昂)的Java 1.8.0_121
这里蚀(氧)是主要的一个SSCE的。
public static void main(String[] args) {
JFileChooser fileChooser = new JFileChooser(".");
int status = fileChooser.showOpenDialog(null);
if (status == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
System.out.println(selectedFile.getParent());
System.out.println(selectedFile.getName());
} else if (status == JFileChooser.CANCEL_OPTION) {
System.out.println("canceled");
}
}
谢谢
仅供参考 - 已检查你的代码,它为我工作在Windows上。你也可以尝试玩一下外观和感觉像[这里](https:// stackoverflow。com/questions/18642158/why-does-jfilechooser-showopendialog-hang-on-mac-osx) –
还有一个[here](http://supunmali-myexperience.blogspot.com.by/2012/10/issue- jfilechooser-on-mac-os-x.html) –
目录权限如何? –