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

InputEvent contains Example Code Error

XMLWordPrintable

    • b79
    • x86
    • windows_2000

      A DESCRIPTION OF THE PROBLEM :
      The example given in the getModifiersEx() method contains an error:

      int onmask = SHIFT_DOWN_MASK | BUTTON1_DOWN_MASK;
          int offmask = CTRL_DOWN_MASK;
          if (event.getModifiersEx() & (onmask | offmask) == onmask) {
              ...
          }

      The error (in Eclipe): "The operator & is undefined for the argument type(s) int, boolean."

      There are () missing. Also in the Java 2 Platform Edition 5.0.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -

      int onmask = SHIFT_DOWN_MASK | BUTTON1_DOWN_MASK;
          int offmask = CTRL_DOWN_MASK;
          if ((event.getModifiersEx() & (onmask | offmask)) == onmask) {
              ...
          }
      ACTUAL -

      int onmask = SHIFT_DOWN_MASK | BUTTON1_DOWN_MASK;
          int offmask = CTRL_DOWN_MASK;
          if (event.getModifiersEx() & (onmask | offmask) == onmask) {
              ...
          }

      URL OF FAULTY DOCUMENTATION :
      http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/InputEvent.html#getModifiersEx()

            son Oleg Sukhodolsky (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: