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

Error in JavaDoc in java.awt.event.KeyEvent

XMLWordPrintable

    • x86
    • other

      FULL PRODUCT VERSION :
      java version "1.8.0_91"
      Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 10 Home
      version 1511
      Build 10586.318
      64 bit x64 bit based processor

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Using
      NetBeans IDE 8.1 (Build 201510222201)
      Java: 1.8.0_60; Java HotSpot(TM) 64-Bit Server VM 25.60-b23
      Runtime: Java(TM) SE Runtime Environment 1.8.0_60-b27

      A DESCRIPTION OF THE PROBLEM :
      I was consulting the Javadoc regarding java.awt.event.KeyEvent for a key pressed event listener.

      Checking the constant value for th back space key I found its value to be indicated as 'static int VK_BACK_SPACE' in the netBeans enveded version and in the in the online version.

      NetBens marked this value as erroneous for being non existent.

      Then I checked the automatic hint given by NetBeans and found it was 'VK_BACKSPACE' without the second under score.

      Not a big deal but still puzzling, time consuming and easy to fix.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      just intoduce VK_BACK_SPACE in the seach box in the javadoc. It will find it as static variable being part of java.awt.event.KeyEvent.

      Create an event listener, for example:
      private void FormKeyHandler(java.awt.event.KeyEvent evt)
      {
            if (evt.getKeyCode() == KeyEvent.VK_BACK_SPACE)
              {System.out.println("backspace pressed");}
      }
      You will see the constant value VK_BACK_SPACE masked as non existing.
      Create a form in the GUI designer and assing this listener to the event keyPressed.
      If you try to run the code you will get a warn about the application possibly not working because of the error in the code but will run.

      If you press any key you will get the expected not constant value error.

      Change VK_BACK_SPACE to VK_BACKSPACE.

      The appication will work as expected.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Explained in 'Steps to Reproduce'
      ACTUAL -
      Explained in 'Steps to Reproduce'

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
        symbol: variable VK_BACK_SPACE
        location: class com.sun.glass.events.KeyEvent
      at ppal.test1.Form.FormKeyHandler(TCMainInterface.java:377)
      at ppal.test1.Form.access$600(TCMainInterface.java:21)
      at ppal.test1.Form$1.keyPressed(TCMainInterface.java:225)
      at java.awt.Component.processKeyEvent(Component.java:6493)
      at java.awt.Component.processEvent(Component.java:6312)
      at java.awt.Container.processEvent(Container.java:2236)
      at java.awt.Window.processEvent(Window.java:2029)
      at java.awt.Component.dispatchEventImpl(Component.java:4891)
      at java.awt.Container.dispatchEventImpl(Container.java:2294)
      at java.awt.Window.dispatchEventImpl(Window.java:2750)
      at java.awt.Component.dispatchEvent(Component.java:4713)
      at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
      at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
      at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
      at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
      at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
      at java.awt.Component.dispatchEventImpl(Component.java:4762)
      at java.awt.Container.dispatchEventImpl(Container.java:2294)
      at java.awt.Window.dispatchEventImpl(Window.java:2750)
      at java.awt.Component.dispatchEvent(Component.java:4713)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:709)
      at java.awt.EventQueue$3.run(EventQueue.java:703)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
      at java.awt.EventQueue$4.run(EventQueue.java:731)
      at java.awt.EventQueue$4.run(EventQueue.java:729)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Explained in 'Steps to Reproduce'
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Explained in 'Steps to Reproduce' (solution)

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: