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

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

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

JMenu.setMnemonic介绍

暂无

代码示例

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

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

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

public GCViewerGuiMenuBar() {
  super();
  
  viewMenuItemMap = new HashMap<>();
  
  fileMenu = new JMenu(LocalisationHelper.getString("main_frame_menu_file"));
  fileMenu.setMnemonic(LocalisationHelper.getString("main_frame_menu_mnemonic_file").charAt(0));
  add(fileMenu);
  
  viewMenu = new JMenu(LocalisationHelper.getString("main_frame_menu_view"));
  viewMenu.setMnemonic(LocalisationHelper.getString("main_frame_menu_mnemonic_view").charAt(0));
  add(viewMenu);
  
  windowMenu = new JMenu(LocalisationHelper.getString("main_frame_menu_window"));
  windowMenu.setMnemonic(LocalisationHelper.getString("main_frame_menu_mnemonic_window").charAt(0));
  add(windowMenu);
  windowMenuCheckBoxGroup = new ButtonGroup();
  helpMenu = new JMenu(LocalisationHelper.getString("main_frame_menu_help"));
  helpMenu.setMnemonic(LocalisationHelper.getString("main_frame_menu_mnemonic_help").charAt(0));
  if ( ! OSXSupport.isOSX()) {
    add(helpMenu);
  }
}

代码示例来源:origin: apache/tika

private void addMenuBar() {
  JMenuBar bar = new JMenuBar();
  JMenu file = new JMenu("File");
  file.setMnemonic(KeyEvent.VK_F);
  addMenuItem(file, "Open...", "openfile", KeyEvent.VK_O);
  addMenuItem(file, "Open URL...", "openurl", KeyEvent.VK_U);
  file.addSeparator();
  addMenuItem(file, "Exit", "exit", KeyEvent.VK_X);
  bar.add(file);
  JMenu view = new JMenu("View");
  view.setMnemonic(KeyEvent.VK_V);
  addMenuItem(view, "Metadata", "metadata", KeyEvent.VK_M);
  addMenuItem(view, "Formatted text", "html", KeyEvent.VK_F);
  addMenuItem(view, "Plain text", "text", KeyEvent.VK_P);
  addMenuItem(view, "Main content", "main", KeyEvent.VK_C);
  addMenuItem(view, "Structured text", "xhtml", KeyEvent.VK_S);
  addMenuItem(view, "Recursive JSON", "json", KeyEvent.VK_J);
  bar.add(view);
  bar.add(Box.createHorizontalGlue());
  JMenu help = new JMenu("Help");
  help.setMnemonic(KeyEvent.VK_H);
  addMenuItem(help, "About Tika", "about", KeyEvent.VK_A);
  bar.add(help);
  setJMenuBar(bar);
}

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

代码示例来源:origin: stackoverflow.com

JMenu fileMenu = new JMenu();
String mnemonic = // string from localization
fileMenu.setMnemonic(KeyStroke.getKeyStroke(mnemonic).getKeyCode());

代码示例来源:origin: org.icepdf.os/icepdf-viewer

public JMenu buildDocumentMenu() {
  JMenu documentMenu = new JMenu(messageBundle.getString("viewer.menu.document.label"));
  documentMenu.setMnemonic(buildMnemonic(messageBundle.getString("viewer.menu.document.mnemonic").charAt(0)));
  addToMenu(documentMenu, buildFirstPageMenuItem());
  addToMenu(documentMenu, buildPreviousPageMenuItem());
  addToMenu(documentMenu, buildNextPageMenuItem());
  addToMenu(documentMenu, buildLastPageMenuItem());
  documentMenu.addSeparator();
  addToMenu(documentMenu, buildSearchMenuItem());
  addToMenu(documentMenu, buildGoToPageMenuItem());
  return documentMenu;
}

代码示例来源: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 createConfigureMenu() {
 JMenu configureMenu = new JMenu("Configure");
 configureMenu.setMnemonic('c');
 configureMenu.add(createConfigureSave());
 configureMenu.add(createConfigureReset());
 configureMenu.add(createConfigureMaxRecords());
 return configureMenu;
}

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-extra

public static JMenu createMenu(String text, char mnemonic) {
  JMenu menu = new JMenu(text);
  menu.setMnemonic(mnemonic);
  return menu;
}

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

protected JMenu createLogLevelMenu() {
 JMenu result = new JMenu("Log Level");
 result.setMnemonic('l');
 Iterator levels = getLogLevels();
 while (levels.hasNext()) {
  result.add(getMenuItem((LogLevel) levels.next()));
 }
 result.addSeparator();
 result.add(createAllLogLevelsMenuItem());
 result.add(createNoLogLevelsMenuItem());
 result.addSeparator();
 result.add(createLogLevelColorMenu());
 result.add(createResetLogLevelColorMenuItem());
 return result;
}

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

JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('f');
exitItem.setMnemonic('x');
exitItem.addActionListener(new CancelListener());
fileMenu.add(exitItem);
JMenu viewMenu = new JMenu("View");
fileMenu.setMnemonic('v');
JMenuItem trimItem = new JCheckBoxMenuItem("Trim leading whitespace");
trimItem.addItemListener(new ItemListener() {
viewMenu.add(trimItem);
JMenuBar menuBar = new JMenuBar();
menuBar.add(fileMenu);

代码示例来源:origin: org.nuiton/nuiton-widgets

public static JMenu createMenu(String text, char mnemonic) {
  JMenu menu = new JMenu(text);
  menu.setMnemonic(mnemonic);
  return menu;
}

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

setJMenuBar(menuBar);
  JMenu fileMenu = new JMenu();
  menuBar.add(fileMenu);
  fileMenu.setText("File");
  fileMenu.setMnemonic(KeyEvent.VK_F);
    fileMenu.add(openMenuItem);
    saveMenuItem.setMnemonic(KeyEvent.VK_S);
    saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
    fileMenu.add(saveMenuItem);
    saveBMFontMenuItem.setMnemonic(KeyEvent.VK_B);
    saveBMFontMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
    fileMenu.add(saveBMFontMenuItem);

代码示例来源:origin: apache/geode

private void createMenu() {
 JMenuBar menuBar = new JMenuBar();
 JMenu sequenceMenu = new JMenu("Sequence");
 sequenceMenu.setMnemonic(KeyEvent.VK_S);
 sequenceMenu.getAccessibleContext()
   .setAccessibleDescription("The only menu in this program that has menu items");
 menuBar.add(sequenceMenu);
 JMenuItem selectGraphs = new JMenuItem("Choose Graphs", KeyEvent.VK_G);
 selectGraphs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.ALT_MASK));
 selectGraphs.getAccessibleContext().setAccessibleDescription("Select what graphs to display");
 selectGraphs.setActionCommand("selectgraphs");
 selectGraphs.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
   showGraphSelector();
  }
 });
 sequenceMenu.add(selectGraphs);
 frame.setJMenuBar(menuBar);
}

代码示例来源:origin: stackoverflow.com

JMenu helpmenu = new JMenu("File");
helpmenu.setMnemonic('F');
JMenuBar menubar = new JMenuBar();
menubar.add(helpmenu);
setJMenuBar(menubar);

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

setJMenuBar(menuBar);
  JMenu fileMenu = new JMenu();
  menuBar.add(fileMenu);
  fileMenu.setText("File");
  fileMenu.setMnemonic(KeyEvent.VK_F);
    fileMenu.add(openMenuItem);
    saveMenuItem.setMnemonic(KeyEvent.VK_S);
    saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
    fileMenu.add(saveMenuItem);
    saveBMFontMenuItem.setMnemonic(KeyEvent.VK_B);
    saveBMFontMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
    fileMenu.add(saveBMFontMenuItem);

代码示例来源:origin: fossasia/neurolab-desktop

fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
fileMenu.getAccessibleContext().setAccessibleDescription("File menu, for opening and saving files.");
fileMenu.add(menuOpenItem);
fileMenu.add(menuSaveItem);

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

/**
 * Create a JMenu labelled with text for the given property key.
 * 
 * @param key
 *            property key
 * @return JMenu
 */
private JMenu makeMenu(String key) {
  JMenu menu = new JMenu(Config.language.getProperty(key));
  menu.setMnemonic(Config.language.getProperty(key).charAt(0));
  return menu;
}

相关文章