apple.awt.fileDialogForDirectories property not working.

Marco Dinacci marco.dinacci at
Mon May 28 08:39:36 PDT 2012


JFileChooser doesn't use a native dialog so it won't be able to list
any directory except I guess for the container
(~/Library/Containers/myapp/Data) and any special directories listed
in the entitlements file.

I just bundled and signed an app with the code below  the result is a
JFileChooser listing my home directory and not showing any icon:

mport javax.swing.JFrame;
import javax.swing.JFileChooser;

public  class FileChooserTest extends JFrame {

    public String selectFolder() {
      JFileChooser chooser = new JFileChooser(System.getProperty("user.home"));
      return chooser.getSelectedFile().getAbsolutePath();


    public static void main(String[] args) {
        System.setProperty("apple.awt.fileDialogForDirectories", "true");

        FileChooserTest fdt = new FileChooserTest();
        String selectedFolder = fdt.selectFolder();

        System.out.println("The selected file was: " + selectedFolder);

        System.setProperty("apple.awt.fileDialogForDirectories", "false");



On 28 May 2012 16:23, niagarasoft20-macosxportdev at
<niagarasoft20-macosxportdev at> wrote:
> Hi Marco,
> Can you clarify the sandbox issue?
> Mike
> It's worse than that, the JFileChooser won't work if the application
> is in a sandbox so I can't use it.
> Which leaves as only solution hacking the awt.FileDialog...

More information about the macosx-port-dev mailing list