Java JMenuItem setMnemonic(JMenuItem item, String label, int index)

Here you can find the source of setMnemonic(JMenuItem item, String label, int index)

Description

set Mnemonic

License

Open Source License

Declaration

public static void setMnemonic(JMenuItem item, String label, int index) 

Method Source Code

//package com.java2s;
/*/*  w w  w  .  j  a  va  2 s  .c o  m*/
 * This file is part of the 3D City Database Importer/Exporter.
 * Copyright (c) 2007 - 2013
 * Institute for Geodesy and Geoinformation Science
 * Technische Universitaet Berlin, Germany
 * http://www.gis.tu-berlin.de/
 * 
 * The 3D City Database Importer/Exporter program is free software:
 * you can redistribute it and/or modify it under the terms of the
 * GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program. If not, see 
 * <http://www.gnu.org/licenses/>.
 * 
 * The development of the 3D City Database Importer/Exporter has 
 * been financially supported by the following cooperation partners:
 * 
 * Business Location Center, Berlin <http://www.businesslocationcenter.de/>
 * virtualcitySYSTEMS GmbH, Berlin <http://www.virtualcitysystems.de/>
 * Berlin Senate of Business, Technology and Women <http://www.berlin.de/sen/wtf/>
 */

import java.util.ResourceBundle;
import javax.swing.JMenuItem;

public class Main {
    public static ResourceBundle I18N;

    public static void setMnemonic(JMenuItem item, String label, int index) {
        try {
            char mnemonic = label.charAt(index);
            item.setMnemonic(mnemonic);
            item.setDisplayedMnemonicIndex(index);
        } catch (IndexOutOfBoundsException e) {
            //
        }
    }

    public static void setMnemonic(JMenuItem item, String labelKey, String indexKey) {
        try {
            setMnemonic(item, I18N.getString(labelKey), Integer.valueOf(I18N.getString(indexKey)));
        } catch (NumberFormatException e) {
            //
        }
    }
}

Related

  1. setAccelerator(JMenuItem menuItem, int key, int mask)
  2. setCtrlAccelerator(final JMenuItem jmi, final char accelerator)
  3. setCtrlAccelerator(JMenuItem jmi, char accelerator)
  4. setEnabled(boolean enabled, JMenuItem... items)
  5. setKeystroke(JMenuItem m, int key)
  6. syncMenuItem(final JMenuItem source, final JMenuItem dest)
  7. updateFilesOpenedMenuItems(File fx, LinkedHashMap filesOpened, ActionListener actionListener)
  8. useCheckAndArrow(JMenuItem menuItem)
  9. useCheckAndArrow(JMenuItem menuItem)