/** * Removes all top-level sub-menus and reassigns their children to the parent menu. * * @param menu The parent menu containing the sub-menus to collapse. */ private static void collapseSubMenus(RadialMenu menu) { final List<RadialMenuItem> menuItems = menu.getItems(false /* includeCorners */); for (RadialMenuItem item : menuItems) { if (item.hasSubMenu()) { final RadialSubMenu subMenu = item.getSubMenu(); final List<RadialMenuItem> subItems = subMenu.getItems(true /* includeCorners */); menu.removeItem(item.getItemId()); menu.addAll(subItems); } } }