Here you can find the source of createMenuItem(String strTitle, String strActionCommand, ActionListener alListener)
Parameter | Description |
---|---|
strTitle | - title |
strActionCommand | - action command |
alListener | - action listener |
public static JMenuItem createMenuItem(String strTitle, String strActionCommand, ActionListener alListener)
//package com.java2s; import java.awt.event.ActionListener; import javax.swing.JMenuItem; public class Main { public static JMenuItem createMenuItem(String strTitle, String strActionCommand, ActionListener alListener) { JMenuItem deleteItem = new JMenuItem(); //set title if (strTitle != null && !strTitle.isEmpty()) { deleteItem.setText(strTitle); }/*from w w w.j av a 2 s.c om*/ //set action command if (strActionCommand != null && !strActionCommand.isEmpty()) { deleteItem.setActionCommand(strActionCommand); } //set action listener if (alListener != null) { deleteItem.addActionListener(alListener); } return deleteItem; } }