Java Code Examples for javax.swing.JMenu#setMnemonic()

The following examples show how to use javax.swing.JMenu#setMnemonic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PCGenMenuBar.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private JMenu createEditMenu()
{
	JMenu menu = new JMenu();
	menu.setText(LanguageBundle.getString("in_mnuEdit"));
	menu.setMnemonic(KeyEvent.VK_E);
	menu.add(new JMenuItem(actionMap.get(PCGenActionMap.ADD_KIT_COMMAND)));
	menu.addSeparator();
	menu.add(tempMenu);
	menu.addSeparator();

	JMenuItem cutMenuItem = new JMenuItem(new DefaultEditorKit.CutAction());
	cutMenuItem.setText("Cut");
	cutMenuItem.setMnemonic(KeyEvent.VK_T);
	menu.add(cutMenuItem);

	JMenuItem copyMenuItem = new JMenuItem(new DefaultEditorKit.CopyAction());
	copyMenuItem.setText("Copy");
	copyMenuItem.setMnemonic(KeyEvent.VK_C);
	menu.add(copyMenuItem);

	JMenuItem pasteMenuItem = new JMenuItem(new DefaultEditorKit.PasteAction());
	pasteMenuItem.setText("Paste");
	pasteMenuItem.setMnemonic(KeyEvent.VK_P);
	menu.add(pasteMenuItem);
	return menu;
}
 
Example 2
Source File: AppMenuBar.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private JMenu createWindowMenu() {
    JMenu window = new JMenu("Window");
    window.setMnemonic('W');

    window.add(
            withMnemonics(
                    withEmptyIcon(
                            withShortCut(Utils.createMenuItem("Test Design", sActionListener))), 'T'));

    window.add(
            withMnemonics(
                    withShortCut(
                            Utils.createMenuItem("Test Execution", sActionListener)), 'E'));
    window.add(
            withMnemonics(
                    withShortCut(
                            Utils.createMenuItem("Dashboard", sActionListener)), 'D'));

    window.add(
            withMnemonics(
                    withShortCut(
                            Utils.createMenuItem("AdjustUI", sActionListener)), 'A'));

    return window;
}
 
Example 3
Source File: AppMenuBar.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private JMenu createHelpMenu() {
    JMenu help = new JMenu("Help");
    help.setMnemonic('H');

    help.add(
            withMnemonics(
                    withEmptyIcon(
                            withShortCut(
                                    Utils.createMenuItem("Help", sActionListener))), 'H'));
    help.add(
            withMnemonics(
                    withShortCut(
                            Utils.createMenuItem("About", sActionListener)), 'A'));
    help.add(
            withMnemonics(
                    withShortCut(
                            Utils.createMenuItem("Show Log", sActionListener)), 'o'));

    return help;
}
 
Example 4
Source File: AmidstMenuBuilder.java    From amidst with GNU General Public License v3.0 6 votes vote down vote up
private JMenu create_File() {
	JMenu result = new JMenu("File");
	result.setMnemonic(KeyEvent.VK_F);
	// @formatter:off
	Menus.item(result, actions::newFromSeed,           "New From Seed ...",          KeyEvent.VK_N, MenuShortcuts.NEW_FROM_SEED);
	Menus.item(result, actions::newFromRandom,         "New From Random Seed",       KeyEvent.VK_R, MenuShortcuts.NEW_FROM_RANDOM_SEED);
	if (FeatureToggles.SEED_SEARCH) {
		Menus.item(result, actions::searchForRandom,   "Search for Random Seed",     KeyEvent.VK_F, MenuShortcuts.SEARCH_FOR_RANDOM_SEED);
	}
	Menus.item(result, actions::openSaveGame,          "Open Save Game ...",         KeyEvent.VK_O, MenuShortcuts.OPEN_SAVE_GAME);
	result.addSeparator();
	Menus.item(result, actions::switchProfile,         "Switch Profile ...",         KeyEvent.VK_P, MenuShortcuts.SWITCH_PROFILE);
	Menus.item(result, actions::exit,                  "Exit",                       KeyEvent.VK_X, MenuShortcuts.EXIT);
	// @formatter:on
	return result;
}
 
Example 5
Source File: ShuffleMenuBar.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
private void setupLinksMenu() {
   JMenu menu = new JMenu(getString(KEY_LINKS));
   buttonToi18nKeyMap.put(menu, () -> getString(KEY_LINKS));
   menu.setMnemonic(KeyEvent.VK_L);
   
   MenuAction latestAction = new MenuAction(() -> getString(KEY_LATEST_LINK), e -> openLink(LATEST_LINK));
   addMenuAction(menu, latestAction);
   
   MenuAction subredditAction = new MenuAction(() -> getString(KEY_SUBREDDIT_LINK), e -> openLink(SUBREDDIT_LINK));
   addMenuAction(menu, subredditAction);
   
   MenuAction guideAction = new MenuAction(() -> getString(KEY_GUIDE_LINK), e -> openLink(GUIDE_LINK));
   addMenuAction(menu, guideAction);
   
   add(menu);
}
 
Example 6
Source File: CAbstractMenuBuilder.java    From binnavi with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the About menu.
 * 
 * @return The created menu.
 */
private JMenu createAboutMenu() {
  final JMenu menu = new JMenu("Help");
  final JFrame parent = getParent();

  menu.setMnemonic('H');

  menu.add(new JMenuItem(new CActionHelp(parent)));
  menu.add(new JMenuItem(new CActionContextHelp(parent)));
  menu.addSeparator();

  menu.add(new JMenuItem(new CStartTutorialAction(parent)));
  menu.addSeparator();

  menu.add(new JMenuItem(new CActionReportBug(parent)));
  menu.add(new JMenuItem(new CCheckForUpdatesAction(parent)));
  menu.add(new JMenuItem(new CActionAbout(parent)));

  return menu;
}
 
Example 7
Source File: MainMenu.java    From tda with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * create the menu for opening recently selected files.
 */
private void createRecentFileMenu() {
    String[] recentFiles = PrefManager.get().getRecentFiles();
    
    recentFilesMenu = new JMenu(ResourceManager.translate("file.recentfiles"));
    recentFilesMenu.setMnemonic(KeyStroke.getKeyStroke(ResourceManager.translate("file.recentfiles.mnem")).getKeyCode());
    if(recentFiles.length > 1) {
        for(int i = 1; i < recentFiles.length; i++) {
            if(!recentFiles[i].equals("")) {
                JMenuItem item = new JMenuItem(recentFiles[i]);
                ((JMenu) recentFilesMenu).add(item);
                item.addActionListener(listener);
            }
        }
    } else {
        recentFilesMenu.setEnabled(false);
    }
}
 
Example 8
Source File: Hiero.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void initializeMenus () {
	{
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		{
			JMenu fileMenu = new JMenu();
			menuBar.add(fileMenu);
			fileMenu.setText("File");
			fileMenu.setMnemonic(KeyEvent.VK_F);
			{
				openMenuItem = new JMenuItem("Open Hiero settings file...");
				openMenuItem.setMnemonic(KeyEvent.VK_O);
				openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
				fileMenu.add(openMenuItem);
			}
			{
				saveMenuItem = new JMenuItem("Save Hiero settings file...");
				saveMenuItem.setMnemonic(KeyEvent.VK_S);
				saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
				fileMenu.add(saveMenuItem);
			}
			fileMenu.addSeparator();
			{
				saveBMFontMenuItem = new JMenuItem("Save BMFont files (text)...");
				saveBMFontMenuItem.setMnemonic(KeyEvent.VK_B);
				saveBMFontMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
				fileMenu.add(saveBMFontMenuItem);
			}
			fileMenu.addSeparator();
			{
				exitMenuItem = new JMenuItem("Exit");
				exitMenuItem.setMnemonic(KeyEvent.VK_X);
				fileMenu.add(exitMenuItem);
			}
		}
	}
}
 
Example 9
Source File: ComponentSource.java    From LoboBrowser with MIT License 5 votes vote down vote up
public JMenu getNavigationMenu() {
  final JMenu menu = new JMenu("Navigation");
  menu.setMnemonic('N');

  if (LoboBrowser.OS_NAME == OS.MAC) {
    menu.add(menuItem("Back", 'B', KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, CMD_CTRL_KEY_MASK), this.actionPool.backAction));
    menu.add(
        menuItem("Forward", 'F', KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, CMD_CTRL_KEY_MASK), this.actionPool.forwardAction));
    menu.add(menuItem("Stop", 'S', KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), this.actionPool.stopAction));
  } else {
    menu.add(menuItem("Back", 'B', "ctrl B", this.actionPool.backAction));
    menu.add(menuItem("Forward", 'F', this.actionPool.forwardAction));
    menu.add(menuItem("Stop", 'S', KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), this.actionPool.stopAction));
  }

  final JMenuItem reloadMenuItem = menuItem("Reload", 'R', KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), this.actionPool.reloadAction);
  reloadMenuItem.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl R"), "reload action");
  reloadMenuItem.getActionMap().put("reload action", this.actionPool.reloadAction);
  menu.add(reloadMenuItem);

  menu.addSeparator();
  menu.add(this.backMoreMenu);
  menu.add(this.forwardMoreMenu);
  menu.add(this.recentHostsMenu);

  return menu;
}
 
Example 10
Source File: InGameMenuBar.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
private void buildReportMenu() {
    // --> Report

    JMenu menu = Utility.localizedMenu("menuBar.report");
    menu.setOpaque(false);
    menu.setMnemonic(KeyEvent.VK_R);

    menu.add(getMenuItem(ReportReligionAction.id));
    menu.add(getMenuItem(ReportLabourAction.id));
    menu.add(getMenuItem(ReportColonyAction.id));
    menu.add(getMenuItem(ReportForeignAction.id));
    menu.add(getMenuItem(ReportIndianAction.id));
    menu.add(getMenuItem(ReportContinentalCongressAction.id));
    menu.add(getMenuItem(ReportMilitaryAction.id));
    menu.add(getMenuItem(ReportNavalAction.id));
    menu.add(getMenuItem(ReportTradeAction.id));
    menu.add(getMenuItem(ReportTurnAction.id));
    menu.add(getMenuItem(ReportRequirementsAction.id));
    menu.add(getMenuItem(ReportCargoAction.id));
    menu.add(getMenuItem(ReportExplorationAction.id));
    menu.add(getMenuItem(ReportHistoryAction.id));
    menu.add(getMenuItem(ReportProductionAction.id));
    menu.add(getMenuItem(ReportEducationAction.id));
    menu.add(getMenuItem(ShowDifficultyAction.id));
    menu.add(getMenuItem(ShowGameOptionsAction.id));
    menu.add(getMenuItem(ShowMapGeneratorOptionsAction.id));

    add(menu);

}
 
Example 11
Source File: CDatabaseNodeMenuBuilder.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
protected JMenu getMenu() {
  final JMenu menu = new JMenu("Database");

  menu.setMnemonic("HK_MENU_DATABASE".charAt(0));

  return menu;
}
 
Example 12
Source File: CPluginOutputDialog.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new log console menu bar object.
 */
public CLogConsoleMenuBar() {
  final JMenu menu = new JMenu("Log");
  menu.setMnemonic("LogMenuMnemonic".charAt(0));

  menu.add(new JMenuItem(new CSaveToFileAction()));

  add(menu);
}
 
Example 13
Source File: MapEditorMenuBar.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
private void buildToolsMenu() {
    // --> Tools
    JMenu menu = Utility.localizedMenu("menuBar.tools");
    menu.setOpaque(false);
    menu.setMnemonic(KeyEvent.VK_T);

    menu.add(getMenuItem(ScaleMapAction.id));
    menu.add(getMenuItem(DetermineHighSeasAction.id));

    add(menu);
}
 
Example 14
Source File: GuiMain.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static JMenu makeDeploymentsMenu(CliGuiContext cliGuiCtx) {
    JMenu metaCmdMenu = new JMenu("Deployments");
    metaCmdMenu.setMnemonic(KeyEvent.VK_D);

    JMenuItem deploy = new JMenuItem(new DeployAction(cliGuiCtx));
    deploy.setMnemonic(KeyEvent.VK_D);
    metaCmdMenu.add(deploy);

    JMenuItem unDeploy = new JMenuItem(new UndeployAction(cliGuiCtx));
    unDeploy.setMnemonic(KeyEvent.VK_U);
    metaCmdMenu.add(unDeploy);

    return metaCmdMenu;
}
 
Example 15
Source File: TripleAMenuBar.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void createLobbyMenu(final InGameLobbyWatcherWrapper watcher) {
  final JMenu lobby = new JMenu("Lobby");
  lobby.setMnemonic(KeyEvent.VK_L);
  add(lobby);
  lobby.add(new EditGameCommentAction(watcher, frame));
  lobby.add(new RemoveGameFromLobbyAction(watcher));
}
 
Example 16
Source File: PreviewPaneUtilities.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static JMenu createMenu( final ActionCategory cat ) {
  final JMenu menu = new JMenu();
  menu.setText( cat.getDisplayName() );
  final Integer mnemonicKey = cat.getMnemonicKey();
  if ( mnemonicKey != null ) {
    menu.setMnemonic( mnemonicKey.intValue() );
  }
  final String toolTip = cat.getShortDescription();
  if ( toolTip != null && toolTip.length() > 0 ) {
    menu.setToolTipText( toolTip );
  }
  return menu;
}
 
Example 17
Source File: CModuleNodeMenuBuilder.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
protected JMenu getMenu() {
  final JMenu menu = new JMenu("Module");

  menu.setMnemonic("HK_MENU_MODULE".charAt(0));

  return menu;
}
 
Example 18
Source File: MainDialog.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
private JMenuBar createMenu() {
	JMenuBar menuBar = new JMenuBar();
	
	//�����鼮����
	JMenu bookMenu = new JMenu("�鼮����(B)");
	bookMenu.setMnemonic(KeyEvent.VK_B);
	bookMenu.add(MenuActions.BOOK_ADD);
	bookMenu.add(MenuActions.BOOK_ADD2);
	bookMenu.add(MenuActions.BOOK_PRICE);
	bookMenu.add(MenuActions.BOOK_SEARCH);
	
	//��������֤����
	JMenu readerMenu = new JMenu("����֤����(R)");
	readerMenu.setMnemonic(KeyEvent.VK_R);
	readerMenu.add(MenuActions.READER_ADD);
	readerMenu.add(MenuActions.READER_OWN);
	readerMenu.add(MenuActions.READER_SEARCH);
	
	//������ܹ���
	JMenu bsMenu = new JMenu("��ܹ���(S)");
	bsMenu.setMnemonic(KeyEvent.VK_S);
	bsMenu.add(MenuActions.BS_ADD);
	bsMenu.add(MenuActions.BS_SEARCH);
	
	//����һ��ͼ����Ĺ���IJ˵�����ֱ���¼�
	JMenu borrowManageMenu=new JMenu();
	borrowManageMenu.setText("������(O)");
	borrowManageMenu.setMnemonic(KeyEvent.VK_O);
	borrowManageMenu.add(MenuActions.BORROW);
	borrowManageMenu.add(MenuActions.RETURN);
	borrowManageMenu.add(MenuActions.BORROW_SEARCH);
	
	//����һ��ϵͳ����˵��һ���û���������
	JMenu sysManageMenu = new JMenu();
	sysManageMenu.setText("ϵͳ����(M)");
	sysManageMenu.setMnemonic(KeyEvent.VK_M);
	
	JMenu userManageMItem=new JMenu("�û�����");
	userManageMItem.add(MenuActions.USER_ADD);
	userManageMItem.add(MenuActions.MODIFY_PASSWORD);
	
	sysManageMenu.add(userManageMItem);
	sysManageMenu.add(MenuActions.DATABASE_BACKUP);
	sysManageMenu.add(MenuActions.EXIT);

	//���˵������˵���
	menuBar.add(bookMenu);
	menuBar.add(readerMenu);
	menuBar.add(borrowManageMenu);
	menuBar.add(bsMenu);
	menuBar.add(sysManageMenu);
	
	return menuBar;
}
 
Example 19
Source File: FontEditor.java    From lsdpatch with MIT License 4 votes vote down vote up
public FontEditor() {
      setTitle("Font Editor");
      setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
      setBounds(100, 100, 415, 324);
      setResizable(false);

      JMenuBar menuBar = new JMenuBar();
      setJMenuBar(menuBar);

      JMenu mnFile = new JMenu("File");
mnFile.setMnemonic(KeyEvent.VK_F);
      menuBar.add(mnFile);

      JMenuItem mntmOpen = new JMenuItem("Open...");
mntmOpen.setMnemonic(KeyEvent.VK_O);
      mntmOpen.addActionListener(this);
      mnFile.add(mntmOpen);

      JMenuItem mntmSave = new JMenuItem("Save...");
mntmSave.setMnemonic(KeyEvent.VK_S);
      mntmSave.addActionListener(this);
      mnFile.add(mntmSave);

      JMenu mnEdit = new JMenu("Edit");
mnEdit.setMnemonic(KeyEvent.VK_E);
      menuBar.add(mnEdit);

      JMenuItem mntmCopy = new JMenuItem("Copy Tile");
      mntmCopy.addActionListener(this);
      mntmCopy.setMnemonic(KeyEvent.VK_C);
      mnEdit.add(mntmCopy);

      JMenuItem mntmPaste = new JMenuItem("Paste Tile");
      mntmPaste.setMnemonic(KeyEvent.VK_P);
      mntmPaste.addActionListener(this);
      mnEdit.add(mntmPaste);

      contentPane = new JPanel();
      contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      setContentPane(contentPane);
      contentPane.setLayout(null);

      fontMap = new FontMap();
      fontMap.setBounds(10, 42, 128, 146);
      fontMap.setTileSelectListener(this);
      contentPane.add(fontMap);

      tileEditor = new TileEditor();
      tileEditor.setBounds(148, 11, 240, 240);
      tileEditor.setTileChangedListener(this);
      contentPane.add(tileEditor);

      fontSelector = new JComboBox();
      fontSelector.setBounds(10, 11, 128, 20);
      fontSelector.setEditable(true);
      fontSelector.addItemListener(this);
      fontSelector.addActionListener(this);
      contentPane.add(fontSelector);

      color1 = new JRadioButton("1");
      color1.setBounds(10, 220, 37, 23);
      color1.addItemListener(this);
      color1.setMnemonic(KeyEvent.VK_1);
      contentPane.add(color1);

      color2 = new JRadioButton("2");
      color2.setBounds(49, 220, 37, 23);
      color2.addItemListener(this);
      color2.setMnemonic(KeyEvent.VK_2);
      contentPane.add(color2);

      color3 = new JRadioButton("3");
      color3.setBounds(88, 220, 37, 23);
      color3.addItemListener(this);
      color3.setSelected(true);
      color3.setMnemonic(KeyEvent.VK_3);
      contentPane.add(color3);

      colorGroup = new javax.swing.ButtonGroup();
      colorGroup.add(color1);
      colorGroup.add(color2);
      colorGroup.add(color3);

      JLabel lblColor = new JLabel("Color:");
      lblColor.setBounds(10, 199, 46, 14);
      contentPane.add(lblColor);
  }
 
Example 20
Source File: TextViewerWindow.java    From LoboBrowser with MIT License 4 votes vote down vote up
private JMenu createFileMenu() {
  final JMenu fileMenu = new JMenu("File");
  fileMenu.setMnemonic('F');
  fileMenu.add(ComponentSource.menuItem("Close", 'C', new CloseAction()));
  return fileMenu;
}