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

NullPointerException when using left/right arrow keys on MenuBar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 8
    • 7u6
    • javafx

      After accessing a Menu by its mnemonic, pressing the left or the right arrow key will result in a NullPointerException.

      Code:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class JavaFXApplication extends Application {

          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage primaryStage) {

              StackPane root = new StackPane();

              MenuBar menuBar = new MenuBar();
              Menu menuFile = new Menu("_File");
              MenuItem menuItem1 = new MenuItem("Foo");

              menuFile.getItems().add(menuItem1);
              menuBar.getMenus().add(menuFile);

              root.getChildren().add(menuBar);

              primaryStage.setScene(new Scene(root, 300, 250));
              primaryStage.show();
          }
      }

      Exception:
      java.lang.NullPointerException
      at com.sun.javafx.scene.control.skin.MenuBarSkin.isMenuEmpty(MenuBarSkin.java:728)
      at com.sun.javafx.scene.control.skin.MenuBarSkin.showNextMenu(MenuBarSkin.java:781)
      at com.sun.javafx.scene.control.skin.MenuBarSkin.access$600(MenuBarSkin.java:81)
      at com.sun.javafx.scene.control.skin.MenuBarSkin$4.handle(MenuBarSkin.java:221)
      at com.sun.javafx.scene.control.skin.MenuBarSkin$4.handle(MenuBarSkin.java:194)
      at com.sun.javafx.scene.control.WeakEventHandler.handle(WeakEventHandler.java:62)
      at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:78)
      at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:202)
      at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:159)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:22)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:31)
      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:722)

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

              Created:
              Updated:
              Resolved:
              Imported: