• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser on Mac OSX

 
Liutauras Vilda
Marshal
Posts: 3200
127
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Liutauras Vilda
Marshal
Posts: 3200
127
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What went wrong on OSX? I have never used Macs.
 
Liutauras Vilda
Marshal
Posts: 3200
127
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Liutauras Vilda
Marshal
Posts: 3200
127
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!