7016942: Revert a refactoring in TooltipManager to allow reflection hack
authoralexp
Mon, 07 Feb 2011 21:15:51 +0300
changeset 8147 b295bba545d3
parent 8146 f1b64e82649f
child 8148 ff3d90bb0503
7016942: Revert a refactoring in TooltipManager to allow reflection hack Reviewed-by: rupashka
jdk/src/share/classes/javax/swing/ToolTipManager.java
--- a/jdk/src/share/classes/javax/swing/ToolTipManager.java	Thu Feb 03 09:59:20 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/ToolTipManager.java	Mon Feb 07 21:15:51 2011 +0300
@@ -75,6 +75,9 @@
     private MouseMotionListener moveBeforeEnterListener = null;
     private KeyListener accessibilityKeyListener = null;
 
+    private KeyStroke postTip;
+    private KeyStroke hideTip;
+
     // PENDING(ges)
     protected boolean lightWeightPopupEnabled = true;
     protected boolean heavyWeightPopupEnabled = false;
@@ -89,6 +92,9 @@
 
         moveBeforeEnterListener = new MoveBeforeEnterListener();
         accessibilityKeyListener = new AccessibilityKeyListener();
+
+        postTip = KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.CTRL_MASK);
+        hideTip =  KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
     }
 
     /**
@@ -805,13 +811,13 @@
         public void keyPressed(KeyEvent e) {
             if (!e.isConsumed()) {
                 JComponent source = (JComponent) e.getComponent();
-                if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+                KeyStroke keyStrokeForEvent = KeyStroke.getKeyStrokeForEvent(e);
+                if (hideTip.equals(keyStrokeForEvent)) {
                     if (tipWindow != null) {
                         hide(source);
                         e.consume();
                     }
-                } else if (e.getKeyCode() == KeyEvent.VK_F1
-                        && e.getModifiers() == Event.CTRL_MASK) {
+                } else if (postTip.equals(keyStrokeForEvent)) {
                     // Shown tooltip will be hidden
                     ToolTipManager.this.show(source);
                     e.consume();