本文整理汇总了Java中java.awt.MenuItem.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setEnabled方法的具体用法?Java MenuItem.setEnabled怎么用?Java MenuItem.setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setEnabled方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register_system_tray_icon
import java.awt.MenuItem; //导入方法依赖的package包/类
@Test
public void register_system_tray_icon() throws ExecutionException, InterruptedException {
final SystemTraySupport systemTraySupport = this.applicationContext.getBean(SystemTraySupport.class);
final MenuItem testItem = new MenuItem("DISABLED_ON_CLICK");
final ActionListener disableOnClick = e -> testItem.setEnabled(false);
final Map<MenuItem, ActionListener> menuItems = new HashMap<MenuItem, ActionListener>() {{
this.put(testItem, disableOnClick);
}};
final SystemTrayIcon trayIcon = this.systemTrayIconWith(menuItems);
systemTraySupport.registerTrayIcon(trayIcon)
.whenCompleteAsync((res, err) -> assertThat(res.isSuccess()).isTrue())
.thenApply(Try::get)
.whenCompleteAsync((res, err) -> assertThat(systemTraySupport.getTrayIcons()).containsExactly(res))
.whenCompleteAsync((res, err) -> systemTraySupport.removeTrayIcon(res))
.thenAccept(icon -> assertThat(systemTraySupport.getTrayIcons()).doesNotContain(icon))
.toCompletableFuture().get();
}
示例2: generateMenuItem
import java.awt.MenuItem; //导入方法依赖的package包/类
private static MenuItem generateMenuItem(TreeElement element) {
if(element.isLeaf()) {
MenuItem item = new MenuItem(element.getCaption());
item.addActionListener(new MasterFrameMenu(element.getFullID()));
if(element.isHidden()) {
item.setEnabled(false);
} else if(!element.getEnabled()) {
item.setEnabled(false);
}
items.put(element.getFullID(), item);
return(item);
} else {
Menu menu = new Menu(element.getCaption());
Iterator<TreeElement> i = element.getChilds();
while(i.hasNext()) {
menu.add(generateMenuItem(i.next()));
}
if(element.isHidden()) {
menu.setEnabled(false);
}
items.put(element.getFullID(), menu);
return(menu);
}
}
示例3: 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);
}
}
示例4: createStop
import java.awt.MenuItem; //导入方法依赖的package包/类
private MenuItem createStop() {
stopItem = new MenuItem(getString("Action.Stop"));
stopItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stop();
}
});
stopItem.setEnabled(false);
return stopItem;
}
示例5: createRestart
import java.awt.MenuItem; //导入方法依赖的package包/类
private MenuItem createRestart() {
restartItem = new MenuItem(getString("Action.Restart"));
restartItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
restart();
}
});
restartItem.setEnabled(false);
return restartItem;
}
示例6: enableMenu
import java.awt.MenuItem; //导入方法依赖的package包/类
private void enableMenu(Menu menu) {
menu.setEnabled(true);
for(int i = 0; i < menu.getItemCount(); i++) {
MenuItem item = menu.getItem(i);
if(item instanceof Menu) {
enableMenu((Menu)item);
} else {
item.setEnabled(true);
}
}
}
示例7: restoreMenu
import java.awt.MenuItem; //导入方法依赖的package包/类
static private void restoreMenu(final Menu menu) {
final int n_menuitems = menu.getItemCount();
for (int i=0; i<n_menuitems; i++) {
final MenuItem menu_item = menu.getItem(i);
if (menu_item instanceof Menu) {
restoreMenu((Menu)menu_item);
}
menu_item.setEnabled(true);
}
}
示例8: deleteConnectionPopup
import java.awt.MenuItem; //导入方法依赖的package包/类
/**
* Popup a menu giving choices for connections to delete (if any)
*
* @param closestConnections a vector containing 0 or more BeanConnections
* @param x the x coordinate at which to popup the menu
* @param y the y coordinate at which to popup the menu
*
* Modified by Zerbetto: javax.swing.JPopupMenu transformed into java.awt.PopupMenu
*/
private void deleteConnectionPopup(Vector closestConnections, int x, int y) {
if (closestConnections.size() > 0) {
int menuItemCount = 0;
// modifications by Zerbetto
//JPopupMenu deleteConnectionMenu = new JPopupMenu();
PopupMenu deleteConnectionMenu = new PopupMenu();
// deleteConnectionMenu.insert(new JLabel("Delete Connection",
// SwingConstants.CENTER),
// menuItemCount);
MenuItem deleteConnection = new MenuItem("Delete Connection:");
deleteConnection.setEnabled(false);
deleteConnectionMenu.insert(deleteConnection, menuItemCount);
menuItemCount++;
for (int i = 0; i < closestConnections.size(); i++) {
final BeanConnection bc = (BeanConnection) closestConnections.elementAt(i);
String connName = bc.getSourceEventSetDescriptor().getName();
//JMenuItem deleteItem = new JMenuItem(connName);
String targetName = "";
if (bc.getTarget().getBean() instanceof BeanCommon) {
targetName = ((BeanCommon)bc.getTarget().getBean()).getCustomName();
} else {
targetName = bc.getTarget().getBean().getClass().getName();
targetName = targetName.substring(targetName.lastIndexOf('.')+1, targetName.length());
}
MenuItem deleteItem = new MenuItem(connName + "-->" + targetName);
deleteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
bc.remove(m_mainKFPerspective.getCurrentTabIndex());
m_beanLayout.revalidate();
m_beanLayout.repaint();
m_mainKFPerspective.setEditedStatus(true);
notifyIsDirty();
}
});
deleteConnectionMenu.add(deleteItem);
menuItemCount++;
}
//deleteConnectionMenu.show(m_beanLayout, x, y);
m_beanLayout.add(deleteConnectionMenu);
deleteConnectionMenu.show(m_beanLayout, x, y);
}
}
示例9: deleteConnectionPopup
import java.awt.MenuItem; //导入方法依赖的package包/类
/**
* Popup a menu giving choices for connections to delete (if any)
*
* @param closestConnections a vector containing 0 or more BeanConnections
* @param x the x coordinate at which to popup the menu
* @param y the y coordinate at which to popup the menu
*
* Modified by Zerbetto: javax.swing.JPopupMenu transformed into
* java.awt.PopupMenu
*/
private void deleteConnectionPopup(Vector closestConnections, int x, int y) {
if (closestConnections.size() > 0) {
int menuItemCount = 0;
// modifications by Zerbetto
// JPopupMenu deleteConnectionMenu = new JPopupMenu();
PopupMenu deleteConnectionMenu = new PopupMenu();
// deleteConnectionMenu.insert(new JLabel("Delete Connection",
// SwingConstants.CENTER),
// menuItemCount);
MenuItem deleteConnection = new MenuItem(
Messages
.getInstance()
.getString(
"KnowledgeFlowApp_DeleteConnectionPopup_DeleteConnection_MenuItem_Text"));
deleteConnection.setEnabled(false);
deleteConnectionMenu.insert(deleteConnection, menuItemCount);
menuItemCount++;
for (int i = 0; i < closestConnections.size(); i++) {
final BeanConnection bc = (BeanConnection) closestConnections
.elementAt(i);
String connName = bc.getSourceEventSetDescriptor().getName();
// JMenuItem deleteItem = new JMenuItem(connName);
String targetName = "";
if (bc.getTarget().getBean() instanceof BeanCommon) {
targetName = ((BeanCommon) bc.getTarget().getBean()).getCustomName();
} else {
targetName = bc.getTarget().getBean().getClass().getName();
targetName = targetName.substring(targetName.lastIndexOf('.') + 1,
targetName.length());
}
MenuItem deleteItem = new MenuItem(connName + "-->" + targetName);
deleteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
bc.remove();
m_beanLayout.revalidate();
m_beanLayout.repaint();
notifyIsDirty();
}
});
deleteConnectionMenu.add(deleteItem);
menuItemCount++;
}
// deleteConnectionMenu.show(m_beanLayout, x, y);
m_beanLayout.add(deleteConnectionMenu);
deleteConnectionMenu.show(m_beanLayout, x, y);
}
}