if (!((JMenu)c).isTopLevelMenu()) { JMenuItem menuItem = new JMenuItem(((JMenu)c).getText(), ((JMenu)c).getIcon()); return menuItem.getMaximumSize(); }
  public Dimension getMaximumSize(JComponent c)  {    // If this menu is in a popup menu, treat it like a regular JMenuItem    if (!((JMenu)c).isTopLevelMenu())      {        JMenuItem menuItem = new JMenuItem(((JMenu)c).getText(), ((JMenu)c).getIcon());        return menuItem.getMaximumSize();      }    return c.getPreferredSize();  }