Here you can find the source of createMenuItem(final String text, final ActionListener al, final int mnemonic)
public static JMenuItem createMenuItem(final String text, final ActionListener al, final int mnemonic)
//package com.java2s; /**/*from w w w. j a va 2 s .co m*/ * Menu creation helper functions * * @author Tamara Orr * See MIT license in license.txt */ import java.awt.event.ActionListener; import javax.swing.JMenuItem; import javax.swing.KeyStroke; public class Main { public static JMenuItem createMenuItem(final String text, final int mnemonic) { return new JMenuItem(text, mnemonic); } public static JMenuItem createMenuItem(final String text, final ActionListener al) { final JMenuItem menuItem = new JMenuItem(text); menuItem.addActionListener(al); return menuItem; } public static JMenuItem createMenuItem(final String text, final ActionListener al, final int mnemonic) { return createMenuItem(text, al, mnemonic, null); } public static JMenuItem createMenuItem(final String text, final ActionListener al, final KeyStroke accelerator) { final JMenuItem menuItem = createMenuItem(text, al); if (accelerator != null) menuItem.setAccelerator(accelerator); return menuItem; } public static JMenuItem createMenuItem(final String text, final ActionListener al, final int mnemonic, final KeyStroke accelerator) { final JMenuItem menuItem = createMenuItem(text, al, accelerator); menuItem.setMnemonic(mnemonic); return menuItem; } public static JMenuItem createMenuItem(final String text, final int mnemonic, final KeyStroke accelerator) { final JMenuItem menuItem = createMenuItem(text, mnemonic); menuItem.setAccelerator(accelerator); return menuItem; } }