if (c != null && c instanceof JMenuItem) { Action action = ((JMenuItem)c).getAction();  if (action != null) ActionUtil.setActionAllowed(action, organizer);
if (c != null) { if (c instanceof JMenu) enableActions((JMenu)c); else if (c instanceof JMenuItem) { Action action = ((JMenuItem)c).getAction(); if (action != null) ActionUtil.setActionAllowed(action, organizer); }
  private void configureMenu(JPopupMenu menu) {    int n = menu.getComponentCount();    for (int i = 0; i < n; i++) {      Component c = menu.getComponent(i);      if (c != null && c instanceof JMenuItem) {        Action action = ((JMenuItem)c).getAction();        // skip submenus which have null actions        if (action != null)          ActionUtil.setActionAllowed(action, organizer);      }    }  }