overriding locale (swing l&f)

I’m trying to get JFileChooser to display in english (defaults to german on my system). While localization is arguably a good thing, right at this moment for these small Swing apps (to be used internally) I don’t want it stuffed down my throat. So I’ve tried all of the following method calls:

from main():
Locale.setDefault(Locale.US);
System.setProperty(“user.language”, “en”);
System.setProperty(“user.country”, “US”);
UIManager.getDefaults().setDefaultLocale(new Locale(“en”, “US”));
JFileChooser.setDefaultLocale(new Locale(“en”, “US”));

and from actionPerformed():
fc.setLocale(new Locale(“en”, “”, “”)); // fc is instance of JFIleChooser

But the dialog box still shows up in german. Now if I pass -Duser.language=en -Duser.region=US to the vm it works just fine, but is there no programmatic way of getting around this? Or am I just missing some very fundamental concept?

I’ve tried this on my machine and it works just fine here. I simply added

static {
  Locale.setDefault(new Locale("fr", "BE"));
}

to the class containing the main method and this has the expected behavior of making swing french.

Are you web-starting (JWS) the app? I don’t know anything about how Locale works, but since JWS loads Swing before any code of your program starts, if Locale must be set at start-up (and can’t be changed) then the VM option in the JNLP file may be the only way to go.

Keith

No JWS, but launched from within Eclipse. Thank you, the static block worked perfectly. =)