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

NullPointer in menuButton on menuItem accelerator key handler

    Details

      Description

      NPE in MenuButtonSkin addAccelerators method.

      It try to access menuParent field of menuItem which is Null, if item added to MenuButton directly.

      {code}
      CheckMenuItem gridSnap = new CheckMenuItem("snap to grid");
                  gridSnap.setSelected(frame.isSnapToGrid());
                  gridSnap.setOnAction(new EventHandler<ActionEvent>() {
                      @Override
                      public void handle(ActionEvent actionEvent) {
                          ...
                      }
                  });

      gridSnap.setAccelerator(KeyCombination.keyCombination("Ctrl+Shift+G"));

      MenuButton mb = new MenuButton();
      mb.getItems().add(gridSnap);
      {code}


      java.lang.NullPointerException
      at com.sun.javafx.scene.control.skin.MenuButtonSkinBase$5.run(MenuButtonSkinBase.java:306)
      at com.sun.javafx.scene.KeyboardShortcutsHandler.processAccelerators(KeyboardShortcutsHandler.java:296)
      at com.sun.javafx.scene.KeyboardShortcutsHandler.dispatchBubblingEvent(KeyboardShortcutsHandler.java:119)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
      at javafx.event.Event.fireEvent(Event.java:171)
      at javafx.scene.Scene$KeyHandler.process(Scene.java:3509)
      at javafx.scene.Scene$KeyHandler.access$2300(Scene.java:3468)
      at javafx.scene.Scene.impl_processKeyEvent(Scene.java:1900)
      at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2266)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:127)
      at com.sun.glass.ui.View.handleKeyEvent(View.java:518)
      at com.sun.glass.ui.View.notifyKey(View.java:951)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
      at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
      at java.lang.Thread.run(Thread.java:662)

        Attachments

          Activity

            People

            • Assignee:
              psomashe Parvathi Somashekar (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:
                Imported: