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

RFE: Mnemonics for non-character keys are displayed incorrectly in the tooltip

XMLWordPrintable

    • beta
    • generic, x86
    • generic, windows_2000



      Name: yyT116575 Date: 10/03/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Classic VM (build 1.3.0-C, native threads, nojit)

      Simply set a mnemonic for a character like HOME (VK_HOME) or RIGHT ARROW
      (VK_RIGHT) on a JButton and look at the tooltip. What displays as the
      Mnemonic is totally incorrect, like for HOME it is Alt-m. For the arrows,
      Alt-' Alt-%, etc... Using the displayed mnemonics don't work (as they
      shouldn't). This is confusing to users who would like to see the right
      thing displayed. Looking at the code MetalToolTipUI.java, the function
      getAcceleratorString() is not correctly getting the mnemonic. First off
      the line char c = (char)keys[i].getKeyCode(); is not needed since c is
      never used. Hopefully, the compiler is smart enought to remove it. But the
      major culprit is:

                    controlKeyStr = KeyEvent.getKeyModifiersText(mod) +
                                   acceleratorDelimiter + (char)keys[i].getKeyCode();

      Casting the keycode to a char seems to be wrong. If we simply do this:

                    controlKeyStr = KeyEvent.getKeyModifiersText(mod) +
                                    acceleratorDelimiter + KeyEvent.getKeyText(keys[i].getKeyCode());

      everything works as expected. I can't see any problem with this approach.
      (Review ID: 110285)
      ======================================================================

            peterz Peter Zhelezniakov
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: