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

[macosx] Command key symbol not shown in key modifier text

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 7u9
    • Fix Version/s: 8
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Introduced In Version:
      7u4
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      Java(TM) SE Runtime Environment (build 1.7.0_09-b05)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X Lion (10.7.4)

      A DESCRIPTION OF THE PROBLEM :
      In Java 7 on Mac the Command key symbol is not return from the method KeyEvent#getKeyModifiersText. Instead the text " Meta " is returned.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached snippet. Move the mouse cursor over the button and notice the tooltip.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The tooltip should be the Command key symbol + F.
      ACTUAL -
      The tooltip is " Meta + F " .

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Toolkit;
      import java.awt.event.KeyEvent;

      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.KeyStroke;

      public class KeyModifierDemo extends JPanel {

        public KeyModifierDemo() {
          final JButton b1 = new JButton( " Button with tooltip " );
          final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
          b1.setToolTipText(getToolTipText(keyStroke));
          add(b1);
        }

        public static String getToolTipText(final KeyStroke keyStroke) {
          final String keyText = KeyEvent.getKeyText(keyStroke.getKeyCode());
          final String modifier = KeyEvent.getKeyModifiersText(keyStroke.getModifiers());
          return (keyStroke.getModifiers() != 0) ? modifier + " + " + keyText : keyText;
        }

        private static void createAndShowGUI() {
          final JFrame frame = new JFrame( " Key modifier demo " );
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          final KeyModifierDemo newContentPane = new KeyModifierDemo();
          frame.setContentPane(newContentPane);
          frame.pack();
          frame.setVisible(true);
        }

        public static void main(final String[] args) {
          javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
              createAndShowGUI();
            }
          });
        }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vkarnauk Vladislav Karnaukhov
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: