Here you can find the source of createMenuItem(final String text, final Icon icon)
public static JMenuItem createMenuItem(final String text, final Icon icon)
//package com.java2s; /* This file is part of the project "Hilbert II" - http://www.qedeq.org * * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>. * * "Hilbert II" is free software; you can redistribute * it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2 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 General Public License for more details. */// w w w . j a v a 2 s.com import javax.swing.Icon; import javax.swing.JMenuItem; import javax.swing.KeyStroke; public class Main { public static JMenuItem createMenuItem(final String text) { return new JMenuItem(text); } public static JMenuItem createMenuItem(final String text, final char mnemonic) { return new JMenuItem(text, mnemonic); } public static JMenuItem createMenuItem(final String text, final char mnemonic, final KeyStroke key) { JMenuItem menuItem = new JMenuItem(text, mnemonic); menuItem.setAccelerator(key); return menuItem; } public static JMenuItem createMenuItem(final String text, final Icon icon) { return new JMenuItem(text, icon); } public static JMenuItem createMenuItem(final String text, final Icon icon, final char mnemonic) { final JMenuItem menuItem = new JMenuItem(text, icon); menuItem.setMnemonic(mnemonic); return menuItem; } public static JMenuItem createMenuItem(final String text, final Icon icon, final char mnemonic, final KeyStroke key) { final JMenuItem menuItem = createMenuItem(text, icon, mnemonic); menuItem.setAccelerator(key); return menuItem; } }