-
Bug
-
Resolution: Duplicate
-
P3
-
7u9
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 ----------
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 ----------
- duplicates
-
JDK-8007212 [macosx] Command key symbol not shown in key modifier text
- Closed