On Mac, the SystemMenuBar sometimes throws an java.lang.IndexOutOfBoundsException.
This happens, when the list of menu items are changed, and some of the previous items were not visible.
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException
at javafx.graphics/com.sun.glass.ui.Menu.insert(Menu.java:134)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSystemMenu.insertMenu(GlassSystemMenu.java:185)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSystemMenu.lambda$insertMenu$1(GlassSystemMenu.java:163)
at javafx.base/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:211)
at javafx.base/javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:162)
at javafx.controls/com.sun.javafx.scene.control.GlobalMenuAdapter.insertItem(GlobalMenuAdapter.java:134)
at javafx.controls/com.sun.javafx.scene.control.GlobalMenuAdapter$2.onChanged(GlobalMenuAdapter.java:106)
at javafx.base/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:211)
at javafx.base/javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:162)
at java.base/java.util.AbstractList.add(AbstractList.java:111)
at com.jpro.hellojpro.TestMenuBar.lambda$createMenuBar$0(TestMenuBar.java:56)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
This happens, when the list of menu items are changed, and some of the previous items were not visible.
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException
at javafx.graphics/com.sun.glass.ui.Menu.insert(Menu.java:134)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSystemMenu.insertMenu(GlassSystemMenu.java:185)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSystemMenu.lambda$insertMenu$1(GlassSystemMenu.java:163)
at javafx.base/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:211)
at javafx.base/javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:162)
at javafx.controls/com.sun.javafx.scene.control.GlobalMenuAdapter.insertItem(GlobalMenuAdapter.java:134)
at javafx.controls/com.sun.javafx.scene.control.GlobalMenuAdapter$2.onChanged(GlobalMenuAdapter.java:106)
at javafx.base/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:211)
at javafx.base/javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:162)
at java.base/java.util.AbstractList.add(AbstractList.java:111)
at com.jpro.hellojpro.TestMenuBar.lambda$createMenuBar$0(TestMenuBar.java:56)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)