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

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

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.2.0, 1.3.0
    • Fix Version/s: 1.4.0
    • Component/s: client-libs
    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      generic, x86
    • OS:
      generic, windows_2000

      Description



      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)
      ======================================================================

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: