Closed amoAHCP closed 8 years ago
Hmm, i think the reason is that the default menu bar has not yet been created at this point. So it is not possible to modify the existing menu structure. On the other hand, a NPE is of course not the nicest exception to throw in that case :wink: What do you thin should be the desired behaviour? If it's possible, it'd probably be nice to postpone the menu bar initialisation until the default menu is created...
fixed with new version
Hi, when you initialize your UI (and the Menu) before stage.show() call you get following exception:
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157) at com.sun.javafx.application.LauncherImpl$$Lambda$1/668386784.run(Unknown Source) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException at de.codecentric.centerdevice.platform.osx.NSMenuBarAdapter.clear(NSMenuBarAdapter.java:158) at de.codecentric.centerdevice.platform.osx.NSMenuBarAdapter.setMenuBar(NSMenuBarAdapter.java:35) at de.saxsys.pitfalls.osxmenu.SampleMenuBar.start(SampleMenuBar.java:55) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821) at com.sun.javafx.application.LauncherImpl$$Lambda$51/1325180719.run(Unknown Source) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323) at com.sun.javafx.application.PlatformImpl$$Lambda$47/947728675.run(Unknown Source) at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292) at com.sun.javafx.application.PlatformImpl$$Lambda$49/1778216420.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291) at com.sun.javafx.application.PlatformImpl$$Lambda$48/1297161816.run(Unknown Source) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)