本文整理了Java中javax.swing.JMenuItem.setAction()
方法的一些代码示例,展示了JMenuItem.setAction()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.setAction()
方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:setAction
暂无
代码示例来源:origin: redwarp/9-Patch-Resizer
private void setMenuBar() {
JMenuBar menuBar = new JMenuBar();
this.setJMenuBar(menuBar);
JMenu mnEdit = new JMenu(Localization.get("menu_edit"));
menuBar.add(mnEdit);
this.mntmClear = new JMenuItem(Localization.get("menu_item_clear"));
this.mntmClear.setAction(this.action);
this.mntmClear.setEnabled(false);
mnEdit.add(this.mntmClear);
JMenu mnHelp = new JMenu(Localization.get("menu_help"));
menuBar.add(mnHelp);
JMenuItem mntmAbout = new JMenuItem();
mntmAbout.setAction(new AboutAction());
mnHelp.add(mntmAbout);
}
代码示例来源:origin: ron190/jsql-injection
public JPopupMenuTable(JTable tableValues, Action actionShowSearchTable) {
this(tableValues);
this.addSeparator();
JMenuItem search = new JMenuItem();
search.setAction(actionShowSearchTable);
search.setText("Search...");
search.setMnemonic('S');
search.setIcon(HelperUi.ICON_EMPTY);
search.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
this.add(search);
}
代码示例来源:origin: ron190/jsql-injection
/**
* Create popup menu for this component.
* @param component The component receiving the menu
*/
public JPopupMenuText(JTextComponent component) {
super(component);
if (component.isEditable()) {
JMenuItem cutItem = new JMenuItem();
cutItem.setIcon(HelperUi.ICON_EMPTY);
cutItem.setAction(component.getActionMap().get(DefaultEditorKit.cutAction));
cutItem.setText("Cut");
cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
cutItem.setMnemonic('t');
JMenuItem pasteItem = new JMenuItem();
pasteItem.setIcon(HelperUi.ICON_EMPTY);
pasteItem.setAction(component.getActionMap().get(DefaultEditorKit.pasteAction));
pasteItem.setText("Paste");
pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
pasteItem.setMnemonic('P');
// Before Copy menu
this.add(cutItem, 0);
// After Copy menu
this.add(pasteItem, 2);
}
}
代码示例来源:origin: ron190/jsql-injection
copyItem.setAction(new ActionCopy());
copyItem.setText(I18n.valueByKey("CONTEXT_MENU_COPY"));
I18nView.addComponentForKey("CONTEXT_MENU_COPY", copyItem);
selectAllItem.setAction(new ActionSelectAll());
selectAllItem.setText(I18n.valueByKey("CONTEXT_MENU_SELECT_ALL"));
I18nView.addComponentForKey("CONTEXT_MENU_SELECT_ALL", selectAllItem);
代码示例来源:origin: ron190/jsql-injection
copyItem.setAction(component.getActionMap().get(DefaultEditorKit.copyAction));
copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
copyItem.setMnemonic('C');
selectAllItem.setAction(component.getActionMap().get(DefaultEditorKit.selectAllAction));
selectAllItem.setText(I18n.valueByKey("CONTEXT_MENU_SELECT_ALL"));
I18nView.addComponentForKey("CONTEXT_MENU_SELECT_ALL", selectAllItem);
JMenuItem clearItem = new JMenuItem();
clearItem.setIcon(HelperUi.ICON_EMPTY);
clearItem.setAction(new AbstractAction() {
代码示例来源:origin: ron190/jsql-injection
itemCopy.setAction(browser.getActionMap().get(DefaultEditorKit.copyAction));
itemCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
itemCopy.setMnemonic('C');
itemSelectAll.setAction(browser.getActionMap().get(DefaultEditorKit.selectAllAction));
itemSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
itemSelectAll.setText(I18n.valueByKey("CONTEXT_MENU_SELECT_ALL"));
代码示例来源:origin: ribomation/DroidAtScreen1
public JMenuItem createMenuItem() {
JMenuItem mi = newMenuItem();
mi.setAction(this);
return mi;
}
代码示例来源:origin: org.fudaa.framework.ebli/ebli-common
public JMenuItem buildMenuItem(final EbliActionSimple _a){
final JMenuItem r = new BuMenuItem();
r.setAction(_a);
return r;
}
代码示例来源:origin: uk.org.mygrid.taverna/taverna-workbench
private JMenuItem makeSwitchProfileMenu() {
JMenuItem revertMenu = new JMenuItem();
revertMenu.setAction(new AbstractAction("Switch version") {
public void actionPerformed(ActionEvent e) {
ProfileVersionListFrame frame=new ProfileVersionListFrame(Workbench.this);
frame.setLocationRelativeTo(Workbench.this);
frame.setVisible(true);
}
});
revertMenu.setToolTipText("Switch to another core Taverna version");
return revertMenu;
}
代码示例来源:origin: stackoverflow.com
public JMenuItem add(Action a) {
JMenuItem mi = createActionComponent(a);
mi.setAction(a);
add(mi);
return mi;
}
代码示例来源:origin: org.nuiton/nuiton-widgets
public static JMenuItem createMenuItem(ApplicationAction action) {
JMenuItem menuItem = new JMenuItem();
menuItem.setAction(action);
menuItem.setText(action.getShortText());
return menuItem;
}
}
代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-extra
public static JMenuItem createMenuItem(ApplicationAction action) {
JMenuItem menuItem = new JMenuItem();
menuItem.setAction(action);
menuItem.setText(action.getShortText());
return menuItem;
}
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
public JMenuItem createMenuItem(Action a, String baseName) {
JMenuItem mi = new JMenuItem();
mi.setAction(a);
configureMenu(mi, baseName);
return mi;
}
代码示例来源:origin: chatty/chatty
public final void setAction(String key, Action action) {
JMenuItem item = menuItems.get(key);
// Preserve icon
Icon icon = item.getIcon();
item.setAction(action);
item.setIcon(icon);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2
public JMenuItem getPopupPresenter() {
JMenuItem menuItem = new JMenuItem();
menuItem.setAction(this);
if (shared.iconResource() != null)
menuItem.setIcon(null);
return menuItem;
}
代码示例来源:origin: igvteam/igv
static public JMenuItem createMenuItem(MenuAction menuItemAction) {
JMenuItem menuItem = new JMenuItem();
menuItem.setAction(menuItemAction);
String text = menuItemAction.getToolTipText();
if (text != null) {
menuItem.setToolTipText(text);
}
return menuItem;
}
代码示例来源:origin: net.sf.taverna.t2.ui-impl/workbench-impl
private void addPerspectiveToVisibilityMenu(final PerspectiveSPI perspective) {
JMenu perspectivemenu = new JMenu(perspective.getText()
+ " perspective");
perspectivemenu.setIcon(perspective.getButtonIcon());
final JMenuItem toggle = new JMenuItem();
toggle.setAction(new HideShowAction(perspective.isVisible() ? "Hide"
: "Show", perspective));
perspectivemenu.add(toggle);
perspectives.get(perspective).setVisible(perspective.isVisible());
perspectiveVisibilityMenu.add(perspectivemenu);
perspectiveVisibilityMap.put(perspective, perspectivemenu);
}
代码示例来源:origin: org.jspresso.framework/jspresso-swing-application
private JMenuItem createMenuItem(IDisplayableAction action, IView<JComponent> view, IActionHandler actionHandler,
Locale locale) {
Action swingAction = getActionFactory().createAction(action, actionHandler, view, locale);
JMenuItem actionItem = createJMenuItem();
actionItem.setAction(swingAction);
return actionItem;
}
代码示例来源:origin: cytoscape/application
private void updateVSMenu() {
applyVisualStyleMenu.removeAll();
final Set<String> vsNames = new TreeSet<String>(Cytoscape.getVisualMappingManager().getCalculatorCatalog().getVisualStyleNames());
for (String name: vsNames) {
final JMenuItem styleMenu = new JMenuItem(name);
styleMenu.setAction(new ApplyVisualStyleAction(name));
applyVisualStyleMenu.add(styleMenu);
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-dlight-visualizers
public StackAction(ThreadState state, MSAState msa, ThreadDumpQuery query) {
putValue(Action.NAME, ThreadStateResources.forState(msa).name);
putValue(Action.SHORT_DESCRIPTION, ThreadStateResources.forState(msa).tooltip);
putValue(Action.SMALL_ICON, new ThreadStateIcon(msa, 10, 10));
putValue(Action.ACTION_COMMAND_KEY, QUERY_STATE_ACTION_COMMAND);
menuItem = new JMenuItem((String)getValue(Action.NAME));
menuItem.setAction(this);
this.query = query;
this.state = state;
}
内容来源于网络,如有侵权,请联系作者删除!