Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SWT/JFace equivalent to JComponent.setDefaultLocale()?

Tags:

java

swt

jface

In Swing, if I want to set the default locale used by components, I can call JComponent.setDefaultLocale(). I want to do the same thing in SWT/JFace, so my JFace dialogs use a locale of my choosing to display the OK/Cancel buttons, etc. Is there an equivalent method in the SWT/JFace API that I can call?

I am aware that I could call Locale.setDefault(), but I would like to avoid this because there are other parts of the application where I need this to be the system default locale, instead of the locale of my choosing.

like image 638
Kevin K Avatar asked Mar 06 '26 07:03

Kevin K


2 Answers

From what I've seen in the source code - especially where the values of IDialogConstants.OK_LABEL and similar constants originate - JFace completely relies on the default locale (Locale.getDefault()). Using SWT directly, e.g. org.eclipse.swt.widgets.MessageBox, will even ignore the Java default locale and display the dialog in the system's locale. So there seem's to be no SWT/JFace equivalent of JComponent.setDefaultLocale().

like image 52
Frettman Avatar answered Mar 07 '26 21:03

Frettman


as far as I know you should be able to use the locale of your choice using :

  • the swt-nl.jar library (to be included in your classpath)
  • setting the user.language library with something like this java -cp ... -Duser.language=fr MainApp

Please check to download the correct swt-nl pack for your needs , different are available ...

HTH jerome

like image 24
romje Avatar answered Mar 07 '26 21:03

romje