Here you can find the source of createJMenuItem(JMenu menu, String text, int mnemonic, int acceleratorKey, String toolTip, ActionListener actionListener)
static public JMenuItem createJMenuItem(JMenu menu, String text, int mnemonic, int acceleratorKey, String toolTip, ActionListener actionListener)
//package com.java2s; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.KeyStroke; public class Main { static public JMenuItem createJMenuItem(JMenu menu, String text, int mnemonic, int acceleratorKey, String toolTip, ActionListener actionListener) { JMenuItem menuItem = new JMenuItem(); menuItem.setText(text);/*from w w w. j ava 2 s . co m*/ if (mnemonic > 0) menuItem.setMnemonic(mnemonic); if (acceleratorKey > 0) menuItem.setAccelerator(KeyStroke.getKeyStroke(acceleratorKey, ActionEvent.CTRL_MASK)); if (toolTip != null) menuItem.setToolTipText(toolTip); if (actionListener != null) menuItem.addActionListener(actionListener); menu.add(menuItem); return (menuItem); } }