| Author |
Unusal JFileChooser behaviour
|
Olivier Legat
Ranch Hand
Joined: Nov 17, 2007
Posts: 176
|
|
Howdy folks,
So I have this primitive code here that worked fine on Windows the last time I ran it:
But now when I run it on Mac something odd happens:
If I break this code before the method I notice that chooser.getFileFilter() returns null This is madness! I just set a few lines ago.Furthermore the filter don't do their job at all... they all show everything.And the "All-Files" filter is displayed.
How? Why is the behavior of this method completely different on Window and Mac?
Thank-you
P.S. I'm developing on Windows using Java 7, but it seems like OSX lion only supports Java 6 (say Apple, correct me if I'm wrong).. Could this be what causes the problem?
|
Olly
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
You can try entering
java -version
javac -version
... at the command line on your Mac.
Don’t know about the file chooser, but I can give a few hints:
If you look at methods like this one, it says “since 1.3”, but I can’t see similar tags about the methods you are using, so that is probably not the explanation. I would have thought that using the wrong version would produce Exceptions like this (unlikely), or (more likely) this, or this.
Put a few println calls in that method, and display the state of the filter just before you return it. Confirm you are actually calling that method. Similarly just before you use the filter the first time. Confirm there are no changes to its state. Also print its hash code; since the hashCode() method is “inherited from Object“, getting two different hash codes will make you suspicious you have not got the same reference.
|
 |
 |
|
|
subject: Unusal JFileChooser behaviour
|
|
|