本文整理汇总了Java中java.awt.MenuItem.setActionCommand方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setActionCommand方法的具体用法?Java MenuItem.setActionCommand怎么用?Java MenuItem.setActionCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setActionCommand方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToRecent
import java.awt.MenuItem; //导入方法依赖的package包/类
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
示例2: createMenu
import java.awt.MenuItem; //导入方法依赖的package包/类
/**
* creates a PopUp menu for the TrayIcon
*
* @return PopUp menu for the TrayIcon
*/
private PopupMenu createMenu() {
PopupMenu menu = new PopupMenu("TimeTray " + this.VERSION);
// about item
MenuItem menuSettings = new MenuItem("Settings");
menuSettings.setActionCommand("settings");
menu.add(menuSettings);
// exit item
MenuItem menuExit = new MenuItem("Quit");
menuExit.setActionCommand("quit");
menu.add(menuExit);
menu.addActionListener(this);
return menu;
}
示例3: createPopupMenu
import java.awt.MenuItem; //导入方法依赖的package包/类
private PopupMenu createPopupMenu() {
final PopupMenu popup = new PopupMenu();
if (allowScreenSwitch) {
MenuItem switchItem = new MenuItem(Main.getString("text.switchscreen"));
switchItem.setActionCommand("switch");
switchItem.addActionListener(this);
// add to popup
popup.add(switchItem);
}
MenuItem exitItem = new MenuItem(Main.getString("text.exit"));
exitItem.setActionCommand("exit");
exitItem.addActionListener(this);
// add to pop-up menu
popup.add(exitItem);
return popup;
}
示例4: initAddCommentMenu
import java.awt.MenuItem; //导入方法依赖的package包/类
/**
* Initializes the context menu for adding Comments.
*/
private static void initAddCommentMenu() {
ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");
addCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.add_comment"));
addCommentItem.setActionCommand(ADD_COMMENT_BLOCK);
addCommentItem.addActionListener(rndBlockMenu);
addCommentMenu.add(addCommentItem);
cloneItem1 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
cloneItem1.setActionCommand(CLONE_BLOCK);
cloneItem1.addActionListener(rndBlockMenu);
addCommentMenu.add(cloneItem1);
addCommentMenuInit = true;
}
示例5: initRemoveCommentMenu
import java.awt.MenuItem; //导入方法依赖的package包/类
/**
* Initializes the context menu for deleting Comments.
*/
private static void initRemoveCommentMenu() {
ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");
removeCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.delete_comment"));
removeCommentItem.setActionCommand(REMOVE_COMMENT_BLOCK);
removeCommentItem.addActionListener(rndBlockMenu);
removeCommentMenu.add(removeCommentItem);
//rndBlockMenu.add(runBlockItem);
cloneItem2 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
cloneItem2.setActionCommand(CLONE_BLOCK);
cloneItem2.addActionListener(rndBlockMenu);
removeCommentMenu.add(cloneItem2);
removeCommentMenuInit = true;
}
示例6: createItems
import java.awt.MenuItem; //导入方法依赖的package包/类
private void createItems()
{
ih = new ItemHandler();
MenuItem info = new MenuItem("(c) UploadR v"+Constants.VERSION +" | shortcuts "+(Constants.KEYS_ENABLED ? "enabled" : "disabled"));
info.setEnabled(false);
this.add(info);
for(byte i=0;i<ItemHandler.items.length;++i)
{
if(ItemHandler.items[i][0].equals("s"))
{
this.addSeparator();
continue;
}
MenuItem item = new MenuItem(ItemHandler.items[i][0]);
item.setActionCommand(ItemHandler.items[i][1]);
item.addActionListener(ih);
this.add(item);
}
}
示例7: addToRecent
import java.awt.MenuItem; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param s
*/
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
示例8: initCanvasMenu
import java.awt.MenuItem; //导入方法依赖的package包/类
/**
* Initializes the context menu for the BlockCanvas
*
*/
private static void initCanvasMenu() {
ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");
arrangeAllBlocks = new MenuItem(uiMessageBundle.getString("ardublock.ui.organize_blocks")); //TODO some workspaces don't have pages
arrangeAllBlocks.setActionCommand(ARRANGE_ALL_BLOCKS);
arrangeAllBlocks.addActionListener(canvasMenu);
canvasMenu.add(arrangeAllBlocks);
canvasMenuInit = true;
}
示例9: createTrayIcon
import java.awt.MenuItem; //导入方法依赖的package包/类
private boolean createTrayIcon() {
try {
// SystemTray.isSupported();
boolean supported = (Boolean) Utils.callStaticMethod(
"java.awt.SystemTray.isSupported");
if (!supported) {
return false;
}
PopupMenu menuConsole = new PopupMenu();
MenuItem itemConsole = new MenuItem("H2 Console");
itemConsole.setActionCommand("console");
itemConsole.addActionListener(this);
itemConsole.setFont(font);
menuConsole.add(itemConsole);
MenuItem itemStatus = new MenuItem("Status");
itemStatus.setActionCommand("status");
itemStatus.addActionListener(this);
itemStatus.setFont(font);
menuConsole.add(itemStatus);
MenuItem itemExit = new MenuItem("Exit");
itemExit.setFont(font);
itemExit.setActionCommand("exit");
itemExit.addActionListener(this);
menuConsole.add(itemExit);
// tray = SystemTray.getSystemTray();
tray = Utils.callStaticMethod("java.awt.SystemTray.getSystemTray");
// Dimension d = tray.getTrayIconSize();
Dimension d = (Dimension) Utils.callMethod(tray, "getTrayIconSize");
String iconFile;
if (d.width >= 24 && d.height >= 24) {
iconFile = "/org/h2/res/h2-24.png";
} else if (d.width >= 22 && d.height >= 22) {
// for Mac OS X 10.8.1 with retina display:
// the reported resolution is 22 x 22, but the image
// is scaled and the real resolution is 44 x 44
iconFile = "/org/h2/res/h2-64-t.png";
// iconFile = "/org/h2/res/h2-22-t.png";
} else {
iconFile = "/org/h2/res/h2.png";
}
Image icon = loadImage(iconFile);
// trayIcon = new TrayIcon(image, "H2 Database Engine",
// menuConsole);
trayIcon = Utils.newInstance("java.awt.TrayIcon",
icon, "H2 Database Engine", menuConsole);
// trayIcon.addMouseListener(this);
Utils.callMethod(trayIcon, "addMouseListener", this);
// tray.add(trayIcon);
Utils.callMethod(tray, "add", trayIcon);
this.trayIconUsed = true;
return true;
} catch (Exception e) {
return false;
}
}