JDK-6348770 : Localized accelerators in JMenuItem
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-11-10
  • Updated: 2011-01-19
  • Resolved: 2006-06-19
Related Reports
Relates :  
Description
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.

Comments
EVALUATION submitter didn't answer, closed this bug
19-06-2006

EVALUATION I suggest the Responsible Engineer for this bug contact the submitter to see if AWT's proposal solves their problem.
06-06-2006

EVALUATION Does the application require a dynamical locale change? If so, I'm afraid it would be hard to fix accelerators; otherwise, wouldn't just Locale.setDefault() do the job? It should be called early on app startup - actually, before toolkit initialization. See 6292739 for details.
16-11-2005

EVALUATION I wonder if this already supported by java.util.Locale and ResourceBundle classes? If it the same as customes needs?
16-11-2005

EVALUATION Fixing this requires a way in AWT to get modifier text for specific locales. Re-assigning to AWT.
15-11-2005