本文整理了Java中javax.swing.JMenuItem.<init>()
方法的一些代码示例,展示了JMenuItem.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.<init>()
方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:<init>
暂无
代码示例来源:origin: log4j/log4j
protected JMenuItem createSelectDescendantsMenuItem(final CategoryNode node) {
JMenuItem selectDescendants =
new JMenuItem("Select All Descendant Categories");
selectDescendants.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
_categoryModel.setDescendantSelection(node, true);
}
}
);
return selectDescendants;
}
代码示例来源:origin: kevin-wayne/algs4
private static JMenuBar createMenuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menuBar.add(menu);
JMenuItem menuItem1 = new JMenuItem(" Save... ");
menuItem1.addActionListener(std);
menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
menu.add(menuItem1);
return menuBar;
}
代码示例来源:origin: pmd/pmd
private void addSaveOptionsTo(JMenu menu) {
JMenuItem saveItem;
for (int i = 0; i < RENDERER_SETS.length; i++) {
saveItem = new JMenuItem("Save as " + RENDERER_SETS[i][0]);
saveItem.addActionListener(new SaveListener((CPDRenderer) RENDERER_SETS[i][1]));
menu.add(saveItem);
}
}
代码示例来源:origin: log4j/log4j
/**
* Creates a Most Recently Used file list to be
* displayed in the File menu
*/
protected void createMRUFileListMI(JMenu menu) {
String[] files = _mruFileManager.getMRUFileList();
if (files != null) {
menu.addSeparator();
for (int i = 0; i < files.length; i++) {
JMenuItem result = new JMenuItem((i + 1) + " " + files[i]);
result.setMnemonic(i + 1);
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
requestOpenMRU(e);
}
});
menu.add(result);
}
}
}
代码示例来源:origin: deathmarine/Luyten
luytenPrefs = configSaver.getLuytenPreferences();
final JMenu fileMenu = new JMenu("File");
fileMenu.add(new JMenuItem("..."));
this.add(fileMenu);
final JMenu editMenu = new JMenu("Edit");
editMenu.add(new JMenuItem("..."));
this.add(editMenu);
final JMenu themesMenu = new JMenu("Themes");
themesMenu.add(new JMenuItem("..."));
this.add(themesMenu);
final JMenu operationMenu = new JMenu("Operation");
operationMenu.add(new JMenuItem("..."));
this.add(operationMenu);
final JMenu settingsMenu = new JMenu("Settings");
settingsMenu.add(new JMenuItem("..."));
this.add(settingsMenu);
final JMenu helpMenu = new JMenu("Help");
helpMenu.add(new JMenuItem("..."));
this.add(helpMenu);
代码示例来源:origin: 4thline/cling
menuItem = new JMenu(entry.getKey().getDetails().getFriendlyName());
for (int i = 0; i < SUPPORTED_INSTANCES; i++) {
final int instanceId = i;
JMenuItem instanceItem = new JMenuItem("Instance: " + i);
instanceItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
presenter.onSendToMediaRenderer(
menuItem = new JMenuItem(
entry.getKey().getDetails().getFriendlyName() + " (Not Compatible)"
);
JMenuItem noRenderersItem = new JMenuItem("No MediaRenderers found...");
noRenderersItem.setEnabled(false);
menuItems.add(noRenderersItem);
代码示例来源:origin: chewiebug/GCViewer
/**
* @see com.tagtraum.perf.gcviewer.view.model.RecentGCResourcesListener#add(com.tagtraum.perf.gcviewer.view.model.RecentGCResourcesEvent)
*/
@Override
public void add(RecentGCResourcesEvent e) {
menu.add(new JMenuItem(new OpenRecent(controller,
e.getResourceNameGroup())),
e.getPosition());
}
代码示例来源:origin: kevin-wayne/algs4
private JMenuBar createMenuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menuBar.add(menu);
JMenuItem menuItem1 = new JMenuItem(" Save... ");
menuItem1.addActionListener(this);
menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
menu.add(menuItem1);
return menuBar;
}
代码示例来源:origin: deathmarine/Luyten
private void buildHelpMenu(JMenu helpMenu) {
helpMenu.removeAll();
JMenuItem menuItem = new JMenuItem("Legal");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
helpMenu.add(menuItem);
JMenu menuDebug = new JMenu("Debug");
menuItem = new JMenuItem("List JVM Classes");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
menuDebug.add(menuItem);
helpMenu.add(menuDebug);
menuItem = new JMenuItem("About");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
代码示例来源:origin: log4j/log4j
protected JMenuItem createExpandMenuItem(final CategoryNode node) {
JMenuItem result = new JMenuItem("Expand All Descendant Categories");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
expandDescendants(node);
}
});
return result;
}
代码示例来源:origin: skylot/jadx
@Override
public void menuSelected(MenuEvent menuEvent) {
recentFiles.removeAll();
File openFile = wrapper.getOpenFile();
String currentFile = openFile == null ? "" : openFile.getAbsolutePath();
for (final String file : settings.getRecentFiles()) {
if (file.equals(currentFile)) {
continue;
}
JMenuItem menuItem = new JMenuItem(file);
recentFiles.add(menuItem);
menuItem.addActionListener(e -> openFile(new File(file)));
}
if (recentFiles.getItemCount() == 0) {
recentFiles.add(new JMenuItem(NLS.str("menu.no_recent_files")));
}
}
代码示例来源:origin: apache/pdfbox
private JMenu createFindMenu()
findMenu = new JMenu("Find");
findMenu.setEnabled(false);
findMenuItem = new JMenuItem("Find...");
findMenuItem.setActionCommand("find");
findMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, SHORCUT_KEY_MASK));
findNextMenuItem = new JMenuItem("Find Next");
if (IS_MAC_OS)
findPreviousMenuItem = new JMenuItem("Find Previous");
if (IS_MAC_OS)
findMenu.add(findMenuItem);
findMenu.add(findNextMenuItem);
findMenu.add(findPreviousMenuItem);
代码示例来源:origin: libgdx/libgdx
private void initializeComponents () {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menuBar.add(menu);
JMenuItem menuItem = new JMenuItem("Open");
menuItem.addActionListener(new ActionListener() {
menu.add(menuItem);
menuItem = new JMenuItem("Save");
menuItem.addActionListener(new ActionListener() {
menu.add(menuItem);
setJMenuBar(menuBar);
代码示例来源:origin: deathmarine/Luyten
private void buildFileMenu(final JMenu fileMenu) {
fileMenu.removeAll();
JMenuItem menuItem = new JMenuItem("Open File...");
menuItem.setAccelerator(
KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
menuItem = new JMenuItem("Close File");
menuItem.setAccelerator(
KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
menuItem = new JMenuItem("Save As...");
menuItem.setAccelerator(
KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
menuItem = new JMenuItem("Save All...");
menuItem.setAccelerator(
KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
clearRecentFiles = new JMenuItem("Clear Recent Files");
menuItem = new JMenuItem("Exit");
代码示例来源:origin: log4j/log4j
protected JMenuItem createPropertiesMenuItem(final CategoryNode node) {
JMenuItem result = new JMenuItem("Properties");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showPropertiesDialog(node);
}
});
return result;
}
代码示例来源:origin: deathmarine/Luyten
JMenuItem menuItem = new JMenuItem(path);
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
recentFiles.add(menuItem);
代码示例来源:origin: tomighty/tomighty
public JPopupMenu create(Action[] items) {
JPopupMenu menu = new JPopupMenu();
if(items != null && items.length > 0) {
for(Action action : items) {
injector.injectMembers(action);
JMenuItem item = new JMenuItem(action);
menu.add(item);
}
menu.addSeparator();
}
JMenu pluginsMenu = new JMenu(messages.get("Plugins"));
pluginsMenu.add(menuItem("Manage", injector.getInstance(ShowPluginManager.class)));
menu.add(menuItem("Options", injector.getInstance(ShowOptions.class)));
menu.add(pluginsMenu);
menu.add(menuItem("About", injector.getInstance(ShowAboutWindow.class)));
menu.addSeparator();
menu.add(menuItem("Close", new Exit()));
return menu;
}
代码示例来源:origin: libgdx/libgdx
private void initializeComponents () {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menuBar.add(menu);
JMenuItem menuItem = new JMenuItem("Open");
menuItem.addActionListener(new ActionListener() {
menu.add(menuItem);
menuItem = new JMenuItem("Save");
menuItem.addActionListener(new ActionListener() {
menu.add(menuItem);
setJMenuBar(menuBar);
代码示例来源:origin: wiztools/rest-client
@Override
public void menuSelected(MenuEvent me) {
List<File> recentFiles = recentFilesHelper.getRecentFiles();
jm_open_recent.removeAll();
for(final File f: recentFiles) {
JMenuItem jmi = new JMenuItem(f.getName());
jmi.setToolTipText(f.getAbsolutePath());
jmi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
FileOpenUtil.open(view, f);
}
});
jm_open_recent.add(jmi);
}
// Add clear option:
if(!recentFilesHelper.isEmpty()) {
jm_open_recent.addSeparator();
JMenuItem jmi = new JMenuItem("Clear");
jmi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
recentFilesHelper.clear();
}
});
jm_open_recent.add(jmi);
}
}
代码示例来源:origin: log4j/log4j
protected JMenuItem createCollapseMenuItem(final CategoryNode node) {
JMenuItem result = new JMenuItem("Collapse All Descendant Categories");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
collapseDescendants(node);
}
});
return result;
}
内容来源于网络,如有侵权,请联系作者删除!