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

Support for converting from char to KeyEvent VK_ keycode

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b55
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Description

      The Swing Applicatioun Framework (JSR-296) supports initializing the
      mnemonic properties of labels and buttons and actions from strings
      that contain a marker, like "Save &As". Presently, there's no
      supported way to determine if the current keyboard has a key that
      matches the marked character. There are some hacks in the existing
      Swing implementation that deal with this:

      AbstractButton#setMnemonic(char) just uppercases it's char if it's
      between 'a' and 'z' and then uses the ascii code. This method is
      deprecated.

      JLabel has the very same hack and it's setMnemonic(char) method is not
      deprecated.

      Using a marker character to identify a mnemonic in a text string is a
      common (and beloved!) simplification vs specifying a mnemonic keycode
      and "displayed mnemonic index" explicitly. We need a way to do this
      that works correctly in general.

      AWTKeyStroke.getAWTKeyStroke(char).getKeyCode() always returns 0
      because it returns a KEY_TYPED event and because apparently KEY_TYPED
      events are supposed to have 0 for a keycode. I have no idea why (the
      javadoc was not illuminating).

      The NetBeans implementation, see Mnemonics#getLatinKeycode in
      http://www.netbeans.org/source/browse/openide/awt/src/org/openide/awt/
      handles this by looking up an additional resource that maps a char to
      a VK_ keycode. This makes it possible to deal with arbitrary
      characters in a marked mnemonic string but is an unneccessary burden
      for the developer.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              yan Yuri Nesterenko
              Reporter:
              hmullersunw Hans Muller (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: