How to install the language in Java?

I am using a Java program with a foreign operating system (Korean / Japanese, etc.). Display of swing components such as FileChooser is in foreign languages ​​that I need to change to English.

java.util.Locale.setDefault(java.util.Locale.ENGLISH); JFileChooser chooser = new JFileChooser(); chooser.setLocale(Locale.ENGLISH); 

And file selection still shows everything - buttons, etc. in these foreign languages. Any idea how to fix this?

My JFilechooser OK / CANCEL button is displayed in Japanese. I am using Japanese windows. How to change this to English?

+4
source share
4 answers

You must set the locale via JComponent.setDefaultLocale() before you create the JFileChooser object.

+6
source

You can specify the language when starting the virtual machine.

java -Duser.language=en -Duser.country=US -Duser.variant=US MainClass

+5
source

I don’t want to point out the obvious, but it’s hard to say that your expectations are based on the code you posted. A simple change of language will not change the Unicode characters that you send to the user interface; he will not translate from one language to another. Changing Locale is necessary, but not enough.

+4
source

You can get it to work with the code below, but the JComponent language is the best option.

 JFileChooser chooser = new JFileChooser(); chooser.setLocale(Locale.getDefault()); chooser.updateUI(); 
+1
source

All Articles