javax.swing.JMenu.add()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中javax.swing.JMenu.add()方法的一些代码示例,展示了JMenu.add()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenu.add()方法的具体详情如下:
包路径:javax.swing.JMenu
类名称:JMenu
方法名:add

JMenu.add介绍

暂无

代码示例

代码示例来源:origin: log4j/log4j

protected JMenu createEditMenu() {
 JMenu editMenu = new JMenu("Edit");
 editMenu.setMnemonic('e');
 editMenu.add(createEditFindMI());
 editMenu.add(createEditFindNextMI());
 editMenu.addSeparator();
 editMenu.add(createEditSortNDCMI());
 editMenu.add(createEditRestoreAllNDCMI());
 return editMenu;
}

代码示例来源:origin: log4j/log4j

protected JMenu createConfigureMenu() {
 JMenu configureMenu = new JMenu("Configure");
 configureMenu.setMnemonic('c');
 configureMenu.add(createConfigureSave());
 configureMenu.add(createConfigureReset());
 configureMenu.add(createConfigureMaxRecords());
 return configureMenu;
}

代码示例来源: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: 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: 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: 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: skylot/jadx

JMenu file = new JMenu(NLS.str("menu.file"));
file.setMnemonic(KeyEvent.VK_F);
file.add(openAction);
file.add(saveAllAction);
file.add(exportAction);
file.addSeparator();
file.add(recentFiles);
file.addSeparator();
file.add(prefsAction);
file.addSeparator();
file.add(exitAction);
JMenu view = new JMenu(NLS.str("menu.view"));
view.setMnemonic(KeyEvent.VK_V);
view.add(flatPkgMenuItem);
view.add(syncAction);
view.add(heapUsageBarMenuItem);
nav.add(textSearchAction);
nav.add(clsSearchAction);
nav.addSeparator();
nav.add(backAction);
nav.add(forwardAction);
tools.add(deobfMenuItem);
tools.add(logAction);
help.add(aboutAction);

代码示例来源: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) {
  helpMenu.add(menuItem);

代码示例来源: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: log4j/log4j

protected JMenu createFileMenu() {
 JMenu fileMenu = new JMenu("File");
 fileMenu.setMnemonic('f');
 JMenuItem exitMI;
 fileMenu.add(createOpenMI());
 fileMenu.add(createOpenURLMI());
 fileMenu.addSeparator();
 fileMenu.add(createCloseMI());
 createMRUFileListMI(fileMenu);
 fileMenu.addSeparator();
 fileMenu.add(createExitMI());
 return fileMenu;
}

代码示例来源:origin: log4j/log4j

protected JMenu createHelpMenu() {
 JMenu helpMenu = new JMenu("Help");
 helpMenu.setMnemonic('h');
 helpMenu.add(createHelpProperties());
 return helpMenu;
}

代码示例来源: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

fileMenu.add(menuItem);
fileMenu.addSeparator();
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) {
fileMenu.add(menuItem);
fileMenu.addSeparator();
fileMenu.add(menuItem);
fileMenu.add(menuItem);
fileMenu.addSeparator();
recentFiles = new JMenu("Recent Files");
fileMenu.add(recentFiles);
fileMenu.add(clearRecentFiles);
  fileMenu.add(menuItem);

代码示例来源: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: log4j/log4j

protected JMenu createViewMenu() {
 JMenu result = new JMenu("View");
 result.setMnemonic('v');
 Iterator columns = getLogTableColumns();
 while (columns.hasNext()) {
  result.add(getLogTableColumnMenuItem((LogTableColumn) columns.next()));
 }
 result.addSeparator();
 result.add(createAllLogTableColumnsMenuItem());
 result.add(createNoLogTableColumnsMenuItem());
 return result;
}

代码示例来源:origin: log4j/log4j

protected JMenu createLogLevelColorMenu() {
 JMenu colorMenu = new JMenu("Configure LogLevel Colors");
 colorMenu.setMnemonic('c');
 Iterator levels = getLogLevels();
 while (levels.hasNext()) {
  colorMenu.add(createSubMenuItem((LogLevel) levels.next()));
 }
 return colorMenu;
}

相关文章