JDK-2151092 : Bugs in menu item layout
  • Type: Backport
  • Backport of: JDK-6458123
  • Component: client-libs
  • Sub-Component: javax.swing
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2007-07-18
  • Updated: 2011-03-09
  • Resolved: 2010-08-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u23 b01Fixed 7Fixed
Description
See the description for jdk7 CR version.

Comments
EVALUATION We have ran the test cases provided by the Ephox and the test case attached with the bugster (WebStartDemo and MenuItemLayoutProblems) Testcase WebStartDemo: In this testcase, the Locale is set to "ar". In this locale, the Menu orientation gets set to Right-to-Left. And in this locale, the Accelerators for some MenuItems don't show up. When removed the Locale setting, MenuItems get displayed in the English and the Orientation changes to Left-to-Right. And everything i.e. Text, Accelerator and Icons get shown properly in English Locale Looks like, customer's logic of changing the Text Orientation in their jar 'editlivejava.jar'. Depending upon the chosen Locale, they set the MenuItem Text, Accelator and it's Orientation. Something like this: setMenuOrientation(menu, ComponentOrientation.LEFT_TO_RIGHT); menuItem = new JMenuItem("English MenuItem Text"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK )); menu.add(menuItem); They will be doing the same thing for Arabic text also. setMenuOrientation(menu, ComponentOrientation.RIGHT_TO_LEFT); menuItem = new JMenuItem("Arabic MenuItem Text"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK| ActionEvent.SHIFT_MASK )
31-03-2010

EVALUATION We were getting the NullPointerException with the fix 6u18 based fixed binary and also with jdk7-b84. And with the following code change in getLeftSideBearing() in SwingUilities2.java ! if (!string.isEmpty() ) { ! res = getLeftSideBearing(c, fm, string.charAt(0)); ! } to: ! if ((string != null) && (!string.isEmpty()) ) { ! res = getLeftSideBearing(c, fm, string.charAt(0)); ! } the NullPointerException got fixed. So this change is required in 6u18 revision as well as in jdk7. Then Herrick pointed out that with the fixed binary (also containing above fix), the MenuItems were not comping up properly in Arabic Locale - e.g. the Accelerator is missing in Arabic for "Remove Formatting" and "Format Painter" MenuItems.. Howerver, it comes up fine in English Locale. Then we Ran both the testcases (Ephox's WebStartDemo and MenuItemLayoutProblems attached to bugster). Testcase WebStartDemo: In the testcase, the Locale is set to "ar". In this locale, the Menu orientation gets set to Right-to-Left. And as you said, in this locale, the Accelerators for some MenuItems don't show up. When I remove the Locale setting, MenuItems get displayed in the English and the Orientation changes to Left-to-Right. And everything i.e. Text, Accelerator and Icons get shown properly in English Locale Looks like, customer's logic of changing the Text Orientation is in their jar 'editlivejava.jar'. In that, depending upon the chosen Locale, they set the MenuItem Text, Accelator and it's Orientation. Something like this: setMenuOrientation(menu, ComponentOrientation.LEFT_TO_RIGHT); menuItem = new JMenuItem("English MenuItem Text"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK )); menu.add(menuItem); They will be doing the same thing for Arabic text also. setMenuOrientation(menu, ComponentOrientation.RIGHT_TO_LEFT); menuItem = new JMenuItem("Arabic MenuItem Text"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK| ActionEvent.SHIFT_MASK )); Can we get the source code of 'editlivejava.jar' ? I want to check when they create the MenuItems with Arabic Text, do they set the expected Accelerator for those MenuItems. Or can you please ask them to check this out in their code. Wherever they are expecting the Accelerator to appear on the MenuItem, are they setting that using 'setAccelerator' for Arabic MenuItems in their code ? And I also tested MenuItemLayoutProblems testcase with and without fix and it works perfect with the fix for both the Orientations. He has given general steps on how they are creating MenuItems and how they are setting text, actions, Accelerator on them; these look fine. My point was that they might be having separate code to create MenuItems with Arabic text and there probably they are missing the expected Accelerator setting. But from your previous mail, this does not seem to be their problem. They don't have any complains with respect to Arabic MenuItems. Let's first understand what is their test case, it's expected behavior and the problem (if any) they are facing with the provided FVB. Instead of using WebStartDemo.java with their editlivejava.jar, can Ephox send a simple reproducible test case with a frame and a couple of menus with Arabic text and accelerator that illustrates the problem We need a simple test case that illustrates the problem with Arabic text and accelerator.
31-03-2010

EVALUATION Please, see the evaluation section of the parent CR. In the fix version for 6u11 I decided to remove problems in all look and feels including GTK and Nimbus. A possible fix version is in the attachment.
18-07-2007