📄 menucommand.java
字号:
package ergo.ui;
// $Id: MenuCommand.java,v 1.5 1999/08/29 02:42:24 sigue Exp $
/*
* Copyright (C) 1999 Carl L. Gay and Antranig M. Basman.
* See the file copyright.txt, distributed with this software,
* for further information.
*/
import java.awt.MenuItem;
import java.awt.MenuShortcut;
import java.awt.event.ActionListener;
/** The MenuCommand class represents Command objects that will be invoked
* via a menu. Adds itself as an ActionListener since a Command is an
* ActionListener. The intention is that there will be a (usually
* anonymous) subclass of MenuCommand for each command. Each such
* subclass must implement the execute() method, which will be called
* when the menu item is selected.
*/
public abstract class MenuCommand extends MenuItem implements Command, ActionListener {
protected MenuCommand () {} // disable default constructor
public MenuCommand (String name, MenuShortcut shortcut) {
super(name, shortcut);
addActionListener(this);
}
public MenuCommand (String name) {
super(name);
addActionListener(this);
}
public void actionPerformed (java.awt.event.ActionEvent event) {
executeCommand(event);
}
public String getName () {
return getLabel();
}
public void setName (String name) {
setLabel(name);
}
// setEnabled is already implemented by MenuItem.
// public void setEnabled (boolean enabled);
} // end class MenuCommand
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -