-
Enhancement
-
Resolution: Not an Issue
-
P4
-
None
-
5.0
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
We are developing an application which is localized in 32 different languages, the application is released in an application suite (with happlications not only written in Java) which can be installed in a language different from the one on the target OS. i.e you can have Swedish as OS language and the application suite on English.
When we use accelerators in JMenuItem the accelerators are showed in the OS language and not in the application locale. I have tracked down the problem to the javax.swing.plaf.basic.BasicMenuItemUI which in its paintMenuItem(...) method calls KeyEvent.KeyEvent.getKeyText(...) and KeyEvent.getKeyModifiersText(...) in order to get the acellerators as text. It turns out that the KeyEvent methods calls Toolkit.getProperty(...) which returns the accerators text from a ResourceBundle called "sun.awt.resources.awt", which is loaded at jre startup.
JUSTIFICATION :
It would be nice to have a solution where the accelerators are localized just like other JComponents are, and if the requested locale is not available on the target OS, it should be possible to supply a resourcebundle along with the application.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When locale is changed in the application, JMenuItem accelerators are updated whith the choosen locale.
ACTUAL -
When locale is changed in the application, JMenuItem accelerators are not updated.
---------- BEGIN SOURCE ----------
Create a JMenu, add some JMenuItems with accelerators.
Change locale on the JMenuItems to a language other than the OS.
No changes to the accelerators are made.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Since the problem lays in the KeyEvent (and Tooltip) I cannot see a way how a workaround could be done.
We are developing an application which is localized in 32 different languages, the application is released in an application suite (with happlications not only written in Java) which can be installed in a language different from the one on the target OS. i.e you can have Swedish as OS language and the application suite on English.
When we use accelerators in JMenuItem the accelerators are showed in the OS language and not in the application locale. I have tracked down the problem to the javax.swing.plaf.basic.BasicMenuItemUI which in its paintMenuItem(...) method calls KeyEvent.KeyEvent.getKeyText(...) and KeyEvent.getKeyModifiersText(...) in order to get the acellerators as text. It turns out that the KeyEvent methods calls Toolkit.getProperty(...) which returns the accerators text from a ResourceBundle called "sun.awt.resources.awt", which is loaded at jre startup.
JUSTIFICATION :
It would be nice to have a solution where the accelerators are localized just like other JComponents are, and if the requested locale is not available on the target OS, it should be possible to supply a resourcebundle along with the application.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When locale is changed in the application, JMenuItem accelerators are updated whith the choosen locale.
ACTUAL -
When locale is changed in the application, JMenuItem accelerators are not updated.
---------- BEGIN SOURCE ----------
Create a JMenu, add some JMenuItems with accelerators.
Change locale on the JMenuItems to a language other than the OS.
No changes to the accelerators are made.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Since the problem lays in the KeyEvent (and Tooltip) I cannot see a way how a workaround could be done.
- relates to
-
JDK-6292739 Locale change at runtime doesn't affect text displayed for accelerator keys
- Open