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

Premature deprecation of Event/InputEvent/KeyEvent in Java 9

    XMLWordPrintable

Details

    • CSR
    • Status: Closed
    • P3
    • Resolution: Approved
    • 10
    • client-libs
    • None
    • behavioral
    • minimal
    • Java API
    • SE

    Description

      Summary

      In Java SE 9 the list of input events, which have an extended equivalent, were marked as deprecated. But there is some API which works with the old version of events only. There are no way to write deprecation-free code, which uses input events, that would compile fine Java 9.

      Problem

      In jdk9 there is no replacement for Toolkit.getMenuShortcutKeyMask() that would return InputEvent.CTRL_DOWN_MASK instead of InputEvent.CTRL_MASK.

      Solution

      The new method which support extended modifiers should be added. The old method which support old modifiers should be deprecated.

      Specification

      #################################################################
      ### src/java.desktop/share/classes/java/awt/Toolkit.java
      #################################################################
      
      +     * @deprecated It is recommended that extended modifier keys and
      +     *             {@link #getMenuShortcutKeyMaskEx()} be used instead
            * @since     1.1
            */
      -    @SuppressWarnings("deprecation")
      +    @Deprecated(since = "10")
           public int getMenuShortcutKeyMask() throws HeadlessException
      
      +    /**
      +     * Determines which extended modifier key is the appropriate accelerator
      +     * key for menu shortcuts.
      +     * <p>
      +     * Menu shortcuts, which are embodied in the {@code MenuShortcut} class, are
      +     * handled by the {@code MenuBar} class.
      +     * <p>
      +     * By default, this method returns {@code InputEvent.CTRL_DOWN_MASK}.
      +     * Toolkit implementations should override this method if the
      +     * <b>Control</b> key isn't the correct key for accelerators.
      +     *
      +     * @return the modifier mask on the {@code InputEvent} class that is used
      +     *         for menu shortcuts on this toolkit
      +     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
      +     *         true
      +     * @see java.awt.GraphicsEnvironment#isHeadless
      +     * @see java.awt.MenuBar
      +     * @see java.awt.MenuShortcut
      +     * @since 10
      +     */
      +    public int getMenuShortcutKeyMaskEx() throws HeadlessException

      Attachments

        Issue Links

          Activity

            People

              serb Sergey Bylokhov
              webbuggrp Webbug Group
              Philip Race
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: