JFileChooser for Mac directories: how to make it not suck?

Directory-only JFileChooser on Mac has two serious problems:

1) You cannot create directories with it

2) You cannot switch discs

This is a pretty big problem for my installer application. As far as I can tell, Apple has nothing to do with this problem, you can’t even activate a non-native choice of directory selection ... so the only alternative is to search for a widget with a clean / open version with open source code.

Does anyone know about this?

+7
java jfilechooser macos
source share
4 answers

How about using java.awt.FileDialog? It shows its own selection of files and allows you to create 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); } 
+5
source share

I found that there is a magic property that you can set, which makes awt filepicker correct:

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

I vaguely recall trying this before when I was on OS X 10.4, and it didn’t work, but now I’m on Leopard and that’s so, so I’m a happy tourist.

+2
source share

I used JFileChooser with the showDialog method and I had no problems. I can create directories and sava as a file with a name that I like. If you use only the showOpenDialog method, you cannot create directories

+2
source share

JFileChooser can see external drives. Scroll down from the root to / Volumes and all disks are listed there. He is not elegant, but he works ...

http://lists.apple.com/archives/java-dev///2008/Feb/msg00079.html

+1
source share

All Articles