MenuLayoutMetrics metrics = new MenuLayoutMetrics();
for (int i = 0; i < popupMenu.getComponentCount(); i++) {
Component comp = popupMenu.getComponent(i);
if (comp instanceof JMenuItem) {
JMenuItem childMenuItem = (JMenuItem) comp;
ButtonUI bui = childMenuItem.getUI();
if (!(bui instanceof SubstanceMenu))
continue;
SubstanceMenu ui = (SubstanceMenu) bui;
MenuLayoutInfo mli = MenuUtilities.getMenuLayoutInfo(
forPainting, childMenuItem, ui.getAcceleratorFont(), ui