JMenuItem getItem() {
      JMenuItem i;

      if (null == cmd) {
        i = new JMenu(name);
        for (MenuElement e : submenu) {
          i.add(e.getItem());
        }
      } else {
        i = new JMenuItem(cmd.name());
        i.setActionCommand(cmd.name());
        i.addActionListener(menuListener);
      }

      return i;
    }
 @Override
 public void actionPerformed(ActionEvent e) {
   processCommand(MenuCmds.valueOf(e.getActionCommand()));
 }
 public void processCommand(MenuCmds cmd) {
   System.out.println("Command: " + cmd.name());
 }