Java tutorial
//package com.java2s; import java.awt.Color; import java.awt.event.ActionListener; import javax.swing.JMenuItem; public class Main { public static JMenuItem buildMenuItem(String text, String actioncmd, ActionListener al) { JMenuItem mi = new JMenuItem(); mi.setBackground(Color.lightGray); mi.setText(text); mi.setActionCommand(actioncmd); mi.addActionListener(al); return mi; } }