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

menu shortkey returns null action event (1.1.x only)

XMLWordPrintable

    • x86
    • windows_95



      Name: mc57594 Date: 06/10/97


      There's a bug in java.awt.MenuItem.java line 229.

      Instead of returning "actionCommand" you should return
      getActionCommand() in the action event since "actionCommand"
      may not have been set and may be null (in which case it should
      return the label -- like in getActionCommand()).

      ---------------------------------------------------
      [chamness 6/10/97] The described code in MenuItem.java is listed.
      (8th line from the bottom.)

          /*
           * Post an ActionEvent to the target (on
           * keydown). Returns true if there is an associated
           * shortcut.
           */
          boolean handleShortcut(KeyEvent e) {
              MenuShortcut s = new MenuShortcut(e.getKeyCode(),
                                   (e.getModifiers() & InputEvent.SHIFT_MASK) > 0);
              if (s.equals(shortcut) && enabled) {
                  // MenuShortcut match -- issue an event on keydown.
                  if (e.getID() == KeyEvent.KEY_PRESSED) {
                      Toolkit.getEventQueue().postEvent(
                                new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
                                                actionCommand));
                  } else {
                      // silently eat key release.
                  }
                  return true;
          }
              return false;
          }

      ======================================================================

            bchristi Brent Christian
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: