Here you can find the source of createMenuitem(String name, ActionListener listener)
public static JMenuItem createMenuitem(String name, ActionListener listener)
//package com.java2s; //License from project: Open Source License import java.awt.event.ActionListener; import javax.swing.JMenuItem; import javax.swing.KeyStroke; public class Main { public static JMenuItem createMenuitem(String name, ActionListener listener) { final JMenuItem button = new JMenuItem(name); button.addActionListener(listener); return button; }//from w w w.j a v a 2 s. c o m public static JMenuItem createMenuitem(String name, ActionListener listener, String keyBind) { final JMenuItem button = new JMenuItem(name); button.addActionListener(listener); button.setAccelerator(KeyStroke.getKeyStroke(keyBind)); return button; } }