コード例 #1
0
    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;
    }
コード例 #2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   processCommand(MenuCmds.valueOf(e.getActionCommand()));
 }
コード例 #3
0
 public void processCommand(MenuCmds cmd) {
   System.out.println("Command: " + cmd.name());
 }