void (@NotNull MenuItemInternal mi, @NotNull ActionMenu am, int deepness, int[] stats) { // exec at EDT // 1. mark all kids to delete mi.clearChildrenSwingRefs(); for (MenuItemInternal cmi : mi.children) { cmi.position = -1; // mark item to be deleted } if (stats != null) stats[STAT_DELETED] += mi.children.size(); // 2. check all children from ActionMenu int itemPos = 0; for (Component each : am.getPopupMenu().getComponents()) { MenuItemInternal cmi = mi.findCorrespondingChild(each); if (cmi == null) { cmi = _createInternalFromSwing(mi, each); if (cmi != null) { cmi.position = itemPos++; mi.children.add(cmi); if (stats != null) ++stats[STAT_CREATED]; if (each instanceof JMenuItem) { cmi.updateBySwingPeer((JMenuItem)each); } } } else { cmi.position = itemPos++; if (stats != null) --stats[STAT_DELETED]; if (each instanceof JMenuItem) { final boolean changed = cmi.updateBySwingPeer((JMenuItem)each); if (stats != null && changed) ++stats[STAT_UPDATED]; } } if (cmi != null) { if (deepness > 1 && (each instanceof ActionMenu jmiEach)) { jmiEach.removeAll(); jmiEach.setSelected(true); jmiEach.fillMenu(); _syncChildren(cmi, jmiEach, deepness - 1, stats); } } } }