in JAVAFX, I am using shortcut by using setMnemonicParsing(true)
code which is from googling is below
VBox mainLayout = new VBox();
MenuBar menuBar = new MenuBar();
Menu menu1 = new Menu("_File");
menu1.setMnemonicParsing(true);
menu1.getItems().addAll(new MenuItem("Menu 1"), new MenuItem("Menu 2"));
Menu menu2 = new Menu("_Other");
menu2.setMnemonicParsing(true);
menu2.getItems().addAll(new MenuItem("Other 1"), new MenuItem("Other 2"));
menuBar.getMenus().setAll(menu1, menu2);
mainLayout.getChildren().setAll(menuBar);
Scene scene = new Scene(mainLayout, 300, 100);
stage.setTitle("Demo of mnemonic");
stage.setScene(scene);
stage.sizeToScene();
stage.show();
here is the steps (window platform)
- press Alt key
- can see mnemonic letter
- press F key
- drop down menu and get focus
- press arrow(->) key
- error like below
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)
but when I click the the Menubar with mouse, it doesn't happen.
any solution?