Reputation: 6226
I am working on a java application with a JFileChooser and the user is able to switch languages.
Locale.setDefault( Locale.ENGLISH );
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog( null );
Locale.setDefault( Locale.CHINA );
JFileChooser.setDefaultLocale( Locale.CHINA );
JFileChooser chinese_chooser = new JFileChooser();
chinese_chooser.showOpenDialog( null );
The second file chooser to appear is in Chinese except for the "All Files" string in the drop down box. If I comment out the first section of code the file chooser appears correctly with all the strings translated.
Is this a bug in java or do I need to set the locale somewhere else?
How can I get the translated file chooser to appear correctly?
Upvotes: 5
Views: 1177
Reputation: 67370
I found something that might help you here. Here's how you change the "All Files" string:
UIManager.put("FileChooser.acceptAllFileFilterText","abc4");
Just put this right before you set the default locale to Locale.CHINA
. It's lame that it's not changed in the locale, but maybe that will give you the work around you need for this to work out for you.
Upvotes: 5