MenuElement[] pathArray = new MenuElement[path.size()]; path.toArray(pathArray); return pathArray; }
  private MenuElement[] getPath (Component c)  {    ArrayList path = new ArrayList();    path.add(0, c);    Component parent = c.getParent ();    while (parent instanceof JMenu            || parent instanceof JPopupMenu            || parent instanceof JMenuItem            || parent instanceof JMenuBar)      {        path.add(0, parent);        parent = parent.getParent ();      }    return (MenuElement[]) path.toArray();  }