Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using FileDialog for to select both files AND directories

 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

For the sake of Mac users I wish to use FileDialog for file/directory selection. I can use:

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

in order to be able to select directories, but it only allows directory selection. Not setting it only allows file selection. I wish to be able to select either a file OR a directory, which I haven't found a way to do.

Anyone know how?

thanks, Allasso
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's possible to switch to JFileChooser you can use its setFileSelectionMode method.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is possible, but JFileChooser does not display files in "column view mode" that Mac users are accustomed to, thus the reason for using FileDialog.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allasso Travesser wrote:it is possible, but JFileChooser does not display files in "column view mode" that Mac users are accustomed to, thus the reason for using FileDialog.


I don't have a mac to test this on, but I wonder if this Look & Feel dependent? If so, then JFileChooser could work out just fine.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, it has the Mac look and feel (sorta) but it displays in what Mac would call "list view mode". I use a Mac and am pretty familiar with this stuff. I know LOTS of Mac users, and "column view mode" is what most of them use. (actually I can't ever remember seeing anyone NOT using column view). I've written several programs that use a file chooser, and I always use FileDialog (if the system detects a Mac) for this reason. Only thing is now I have an application that needs to have the option of selecting either a folder or file.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BeForthrightWhenCrossPostingToOtherSites
http://forums.sun.com/thread.jspa?threadID=5451009
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:BeForthrightWhenCrossPostingToOtherSites
http://forums.sun.com/thread.jspa?threadID=5451009


Mia Culpa.

Thank you, Darryl, I just read the etiquette on this in the "How to ask" section. My apologies.

Please forgive if I have ticked anyone off.

Allasso
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allasso Travesser wrote:I always use FileDialog (if the system detects a Mac)

+1. It's the right thing to do on OS X.

Only thing is now I have an application that needs to have the option of selecting either a folder or file.

Check out the "apple.awt.fileDialogForDirectories" property: http://lists.apple.com/archives/java-dev/2010/May/msg00149.html

The "com.apple.macos.use-file-dialog-packages" property may also be of interest in that context: http://developer.apple.com/legacy/mac/library/#technotes/tn/tn2042.html
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lester Burnham wrote:Check out the "apple.awt.fileDialogForDirectories" property: http://lists.apple.com/archives/java-dev/2010/May/msg00149.html


Thanks, Lester, that is what I always use. But as I said in the OP, when that is set true, ONLY directories are selectable. Am I missing something here that you are trying to point out to me?

The "com.apple.macos.use-file-dialog-packages" property may also be of interest in that context: http://developer.apple.com/legacy/mac/library/#technotes/tn/tn2042.html


Thanks, I'll look into that and let you know the outcome.

Allasso
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I missing something here that you are trying to point out to me?

Arg, sorry, I totally overlooked that that was precisely what you mentioned.

Thanks, I'll look into that and let you know the outcome.

It won't help with your problem, it's just something to be aware of (and potentially use) if the distinction between files and directories is important.
 
Allasso Travesser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lester Burnham wrote:It won't help with your problem, it's just something to be aware of (and potentially use) if the distinction between files and directories is important.


Yes, I saw that, and I really appreciate you pointing that out to me. I was unaware of that, and it is something I will use to keep users from navigating into bundles.

Thanks, Allasso
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic