Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Please ask technical questions in the appropriate category. Thank you!

Localized Accelorator Keys

843806Feb 7 2008 — edited Feb 20 2008
Hi folks,
I have a problem with localization and accelerator keys. I am developing a localized Swing GUI where a user can set his preffered Locale and then all texts are translated.... That's all no prob. The problem is, that in JMenus the accelerator keys for items are displayed not according to the set default locale (e.g., en-US) but are displayed according to the OS user.language (in my case de [German]). Hence, the accel. keys read, e.g., '*Strg-N*' instead of '*Ctrl-N*' as expected for default locale en.

This is just a display problem, the functionality / the keys work fine, of course.

I guess my prob is (somehow) related to the awt.properties. When invoking, e.g.,
KeyEvent.getKeyModifiersText(keyStroke.getModifiers() 
(which I assume is called for JMenuItems to display the acc keys) I get the modifier key as string in German. These properties are loaded on startup? according to the OS user language. If i change my user language (e.g., with the jvm switch
-Duser.language=en
) everything is fine. When changing this system property inside Java Code (e.g. in my main-method) the awt.properties are already loaded (somehow) with the OS user.language. Hence, this option doesn't work.

Has anybody an idea / workaround how I get these modifier keys displayed localized. Is there perhaps a way to change the awt-property on runtime or, at least, to set the values of these properties, e.g. AWT.control?

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2008
Added on Feb 7 2008
9 comments
824 views