Forums Register Login

JFileChooser on Mac OSX

+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:That is not how you use a file chooser.



Liutauras Vilda wrote:Will try it tonight



docs.oracle.com wrote:Bringing up a standard open dialog requires only two lines of code:

//Create a file chooser
final JFileChooser fc = new JFileChooser();
...
//In response to a button click:
int returnVal = fc.showOpenDialog(aComponent);




Cannot make it work on os x. No compile errors, no exceptions thrown. Just requires to terminate program manually (on windows works perfectly fine in both ways: my previous and suggested by docs.oracle.com and Ritchie).

Might someone had an experience with javax.swing.JFileChooser class on os x platform?
Because at the moment it makes me think, that on os x simply it's not working.
And if it is a case, then JAVA ended up it's career as "platform independent" language (joking about this part)
+Pie Number of slices to send: Send
Are you able to use a simple FileDialog (java.awt.FileDialog) instead?

It has limited functionality, but I tend to use it when I can for a true native file chooser.

+Pie Number of slices to send: Send
I haven't tried FileDialog (i'll try), but the idea, that we had a discussion, which states, that the same code you should write for both platforms, windows, os x or linux.

So I just gave an example, when it is not a case, as I cannot make a file chooser work.
Guys mentioned that i'm using it in a wrong way, so i tried to do it exactly by the docs.oracle.com tutorial. But didn't manage to make it work (on windows works perfectly fine, on os x - not).

Was wondering is anyone else had this issue.

+Pie Number of slices to send: Send
What went wrong on OSX? I have never used Macs.
+Pie Number of slices to send: Send
As I mentioned before, file chooser simply doesn't come up (compiling with no errors)
Tried your suggested way, tried docs.oracle.com tutorial's way - file chooser doesn't appear.

It seems that guys experiencing more different problems with JFileChooser class on OS X.

Ritchie, don't waste your time on this thread as it is not important for me at the moment to make it work on OS X.
I just noticed that difference, that not always the same java code working on windows and OS X platforms.
+Pie Number of slices to send: Send
No, this is important, to confirm whether Java® works the same on all OSs.
Try it on a Mac, then minimise all other windows on screen one by one.
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:No, this is important, to confirm whether Java® works the same on all OSs.
Try it on a Mac, then minimise all other windows on screen one by one.



Tried to create only JFileChooser and nothing else. Luckily it's working.



The problem might appears because I using JOptionPane.showInputDialog firstly for a particular reason, then JFileChooser.showOpenDialog. It might clashes on OS X for some reason in my code, because on windows I do not experience such a problem.

+Pie Number of slices to send: Send
There should be no clashes between an input Dialogue and a file chooser, except that the Dialogue is usually modal and will prevent anything else responding until it is dismissed.
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3963 times.
Similar Threads
How To Painlessly Install JRE And Application To Mac For End-user?
JFileChooser Filter Problem
HELP! me pls i can't open image on JLabel
File Chooser Dialog box
closing a jFileChooser window
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:20:35.