Here's my problem. I have a Java application that runs on MacOS X. Right now I'm trying to make this application available on the Mac App Store. Unfortunately, Apple always reject my application because I'm not using the native FileDialog to access files and directories. In some cases the user has to select files in other he has to select directories. Here's what I've tried to create a directory chooser:

// Go in directory chooser mode
System.setProperty("apple.awt.fileDialogForDirectories", "true");
FileDialog dialog = new FileDialog(tamaggoApp.getFrame());
dialog.setDirectory(defaultDir);
dialog.setVisible(true);

// Set back the property to file chooser.
System.setProperty("apple.awt.fileDialogForDirectories", "false");

Unfortunately, it doesn't work for me. It seems that this property has to be set in the main() method so you can't toggle between file and directory choose. Using Swing JFileChooser is not an option since Apple will reject it (I tried).

有帮助吗?

解决方案

I finally figured out that it was working all the time with jdk1.7u21. The problem is you can select a directory but you still can choose files also. I will have to find a way to avoid that which doesn't seem to be easy when I look in forums.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top