Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localizing the JFileChooser "All Files" string

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?

like image 855
Kara Avatar asked Oct 04 '22 20:10

Kara


1 Answers

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.

like image 70
Daniel Kaplan Avatar answered Oct 07 '22 18:10

Daniel Kaplan