/* * @(#)CommandMenu.java * * Project: JHotdraw - a GUI framework for technical drawings * http://www.jhotdraw.org * http://jhotdraw.sourceforge.net * Copyright: © by the original author(s) and all contributors * License: Lesser GNU Public License (LGPL) * http://www.opensource.org/licenses/lgpl-license.html */ package CH.ifa.draw.contrib; import CH.ifa.draw.util.Command; import javax.swing.JMenuItem; import javax.swing.Icon; /** * CommandMenuItem implements a command that can be added to a menu * as a menu item * * @author Eduardo Francos - InContext * @created 2 mai 2002 * @version 1.0 */ public class CommandMenuItem extends JMenuItem implements CommandHolder{ Command fCommand; /** * Creates a menuItem with no set text or icon. */ public CommandMenuItem(Command command) { super(command.name()); setCommand(command); } /** * Creates a menuItem with an icon. * * @param icon the icon of the MenuItem. */ public CommandMenuItem(Command command, Icon icon) { super(command.name(), icon); setCommand(command); } /** * Creates a menuItem with the specified text and * keyboard mnemonic. * * @param text the text of the MenuItem. * @param mnemonic the keyboard mnemonic for the MenuItem */ public CommandMenuItem(Command command, int mnemonic) { super(command.name(), mnemonic); setCommand(command); } /** * Gets the command attribute of the CommandMenuItem object * * @return The command value */ public Command getCommand() { return fCommand; } /** * Sets the command attribute of the CommandMenuItem object * * @param newCommand The new command value */ public void setCommand(Command newCommand) { fCommand = newCommand; } }