Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8022079

[macosx] swing shortcuts are counterintuitive with non-english keyboard layouts

    Details

      Description

      FULL PRODUCT VERSION :
      java version " 1.7.0_40-ea "
      Java(TM) SE Runtime Environment (build 1.7.0_40-ea-b28)
      Java HotSpot(TM) 64-Bit Server VM (build 24.0-b47, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Model Name:Mac mini
        Model Identifier:Macmini6,2
        Processor Name:Intel Core i7
        Processor Speed:2.3 GHz
        Number of Processors:1
        Total Number of Cores:4
        L2 Cache (per Core):256 KB
        L3 Cache:6 MB
        Memory:16 GB

      A DESCRIPTION OF THE PROBLEM :
      At least, on Mac OS X usage of user shortcuts (JMenuItem.setAccelerator) is contra-intuitive with non-english keyboard layouts.

      User with a German or French keyboard should search through all keys to find the assigned shortcut. Text on the menu item is not corresponded to the actual keys.

        To illustrate the problem I have written the next manual test case. I am ready to write an automatic one if the issue will be considered as a bug.

      WINDOWS PLATFORM:
      On Windows toolkit the problem is less harmful. At least, KeyboardManager.fireKeyboardAction takes into account the extended key code. But If you try to assign a German symbol '??' (minus sign on the English keyboard), the KeyboardManager.fireKeyboardAction interprets it as an undefended symbol what is basically not true, taking into account that the e.getKeyChar() returns absolutely correct value - '??'.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Add a system layout (let's it be German)
          * On Mac OS X : System Preferences -> Language & Text -> Input Sources -> enable 'German' checkbox
      2. Run the code
      3. Turn on the English layout.
      4. Press ctrl-'-' on English keyboard
      5. Note that a text is printed in the console
      6. Switch layout to german one
      7. Press ctrl-'-' on English keyboard
      8. Note that a text is printed in the console
      9. Press ctrl-'/' on the English keyboard
      10. Note that a text is NOT printed in the console

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Steps 7 and 9 should be inverted. Because on german keyboard user does not see '-' on the key where it is placed on the english keyboard.
      ACTUAL -
      Shortcuts are associated with key codes not characters.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class LayoutInsensitiveManualTest {
          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      JFrame jFrame = new JFrame();
                      JMenuBar jMenuBar = new JMenuBar();
                      JMenu jMenu = new JMenu( " First menu " );
                      JMenuItem jMenuItem = new JMenuItem( " First menu item " );

                      jMenuItem.addActionListener(new ActionListener() {
                          @Override
                          public void actionPerformed(ActionEvent e) {
                              System.err.println( " Action performed on the menu item " );
                          }
                      });

                      // '-' is presented on German and English layout without pressing shift modifier key
                      jMenuItem.setAccelerator(KeyStroke.getKeyStroke('-', KeyEvent.CTRL_MASK));
                      jMenu.add(jMenuItem);
                      jMenuBar.add(jMenu);
                      jFrame.setJMenuBar(jMenuBar);
                      jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                      jFrame.setSize(200,200);
                      jFrame.setVisible(true);
                  }
              });
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      It would be possible to workaround the issue if the javax.swing.KeyboardManager was not package private. By modifying KeyboardManager.fireKeyboardAction method

        Activity

        Hide
        vdyakov Victor Dyakov added a comment -
        The criteria for deferral bulk request bugs:
        - Not P2
        - Not tck-red or conformance labeled
        - Not regressions reported/labeled against jdk8
        - Not findbugs, parfait, eht, fuzzing labeled
        - Not netbeans, licbug, cap, cap-8 labeled against jdk8
        Show
        vdyakov Victor Dyakov added a comment - The criteria for deferral bulk request bugs: - Not P2 - Not tck-red or conformance labeled - Not regressions reported/labeled against jdk8 - Not findbugs, parfait, eht, fuzzing labeled - Not netbeans, licbug, cap, cap-8 labeled against jdk8
        Hide
        vdyakov Victor Dyakov added a comment -
        We've reviewed your bulk request (120 bugs) and are OK with deferring them to JDK 9. You can go ahead and update these to:

        - Set label to 8-defer-approved
        - FixVersion to 9

        Thanks for doing a great job of summarizing the details for the bulk deferral for us!

        Kind regards,
        Mathias
        Show
        vdyakov Victor Dyakov added a comment - We've reviewed your bulk request (120 bugs) and are OK with deferring them to JDK 9. You can go ahead and update these to: - Set label to 8-defer-approved - FixVersion to 9 Thanks for doing a great job of summarizing the details for the bulk deferral for us! Kind regards, Mathias
        Hide
        vdyakov Victor Dyakov added a comment -
         - this is an issue reported against 7(7u),
         - there are now affected version 9 filed for this issue
         - 7u issues are transferred to Sustaining
        Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9
        or
        7u specific escalations might be reopen to Sustaining
        Show
        vdyakov Victor Dyakov added a comment -  - this is an issue reported against 7(7u),  - there are now affected version 9 filed for this issue  - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
        Hide
        vdyakov Victor Dyakov added a comment -
         - this is an issue reported against 7(7u),
         - there are now affected version 9 filed for this issue
         - 7u issues are transferred to Sustaining
        Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9
        or
        7u specific escalations might be reopen to Sustaining
        Show
        vdyakov Victor Dyakov added a comment -  - this is an issue reported against 7(7u),  - there are now affected version 9 filed for this issue  - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
        Hide
        sla Staffan Larsen (Inactive) added a comment -
        Verified on 8u31 and 9 with Swedish keyboard.
        Show
        sla Staffan Larsen (Inactive) added a comment - Verified on 8u31 and 9 with Swedish keyboard.

          People

          • Assignee:
            sveerabhadra Shashidhara Veerabhadraiah
            Reporter:
            webbuggrp Webbug Group
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated: