modules/graphics/src/main/java/com/sun/javafx/tk/quantum/GlassSystemMenu.java

Print this page

        

@@ -152,13 +152,17 @@
         items.addListener((ListChangeListener.Change<? extends MenuItemBase> change) -> {
             while (change.next()) {
                 int from = change.getFrom();
                 int to = change.getTo();
                 List<? extends MenuItemBase> removed = change.getRemoved();
+
                 for (int i = from + removed.size() - 1; i >= from ; i--) {
+                    List<Object> menuItemList = glassMenu.getItems();
+                    if (i >= 0 && menuItemList.size() > i) {
                     glassMenu.remove(i);
                 }
+                }
                 for (int i = from; i < to; i++) {
                     MenuItemBase item = change.getList().get(i);
                     if (item instanceof MenuBase) {
                         insertMenu(glassMenu, (MenuBase)item, i);
                     } else {