/** * Creates a menu item for the given command group. * * @param commandGroup the command group, must not be <code>null</code> * * @return the menu item */ public JMenuItem createMenuItem(CommandGroup commandGroup) { JMenu menu = new JMenu(commandGroup.getAction()); menu.setName(commandGroup.getCommandID()); // Ensure that the menu has some text, so that is guranteed to be visible for the user if (menu.getText() == null) { menu.setText(commandGroup.getCommandID()); } enableHelp(menu, commandGroup); return menu; }
/** * Creates a menu item for the given executable command. * * @param command the executable command, must not be <code>null</code> * * @return the menu item */ public JMenuItem createMenuItem(ExecCommand command) { JMenuItem menuItem; if (command.isToggle()) { JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem(command.getAction()); installMutualExclusiveInterest(checkBoxMenuItem, command); menuItem = checkBoxMenuItem; } else { menuItem = new JMenuItem(command.getAction()); } menuItem.setName(command.getCommandID()); KeyStroke keyStroke = command.getAccelerator(); if (keyStroke != null) { menuItem.setAccelerator(keyStroke); } // Ensure that the menu item has some text, so that is guranteed to be visible for the user if (menuItem.getText() == null) { menuItem.setText(command.getCommandID()); } enableHelp(menuItem, command); return menuItem; }