Here you can find the source of createJMenuItem(Action action)
public static JMenuItem createJMenuItem(Action action)
//package com.java2s; import java.awt.event.ActionListener; import javax.swing.Action; import javax.swing.JMenuItem; public class Main { /**/*from w w w . j av a 2 s . c o m*/ * Creates a menu item from specified action. */ public static JMenuItem createJMenuItem(Action action) { JMenuItem item = new JMenuItem(action); item.setActionCommand((String) action.getValue(Action.ACTION_COMMAND_KEY)); return item; } /** * Creates a menu item with specified name and acton command. */ public static JMenuItem createJMenuItem(String name, String command, ActionListener listener) { JMenuItem item = new JMenuItem(name); item.setActionCommand(command); item.addActionListener(listener); return item; } }