Here you can find the source of createMenuItemCustomAction(JMenu menu, int type, String text, String command, ImageIcon image, int acceleratorKey, String toolTip, ActionListener action)
public static JMenuItem createMenuItemCustomAction(JMenu menu, int type, String text, String command, ImageIcon image, int acceleratorKey, String toolTip, ActionListener action)
//package com.java2s; //License from project: LGPL import javax.swing.*; import java.awt.event.ActionListener; public class Main { public static final int RADIO = 1; public static final int CHECK = 2; public static JMenuItem createMenuItemCustomAction(JMenu menu, int type, String text, String command, int acceleratorKey, ActionListener action) { return createMenuItemCustomAction(menu, type, text, command, null, acceleratorKey, null, action); }/*from w ww .ja v a 2 s . c o m*/ public static JMenuItem createMenuItemCustomAction(JMenu menu, int type, String text, String command, int acceleratorKey, String toolTip, ActionListener action) { return createMenuItemCustomAction(menu, type, text, command, null, acceleratorKey, toolTip, action); } public static JMenuItem createMenuItemCustomAction(JMenu menu, int type, String text, String command, ImageIcon image, int acceleratorKey, String toolTip, ActionListener action) { JMenuItem item; switch (type) { case RADIO: item = new JRadioButtonMenuItem(); break; case CHECK: item = new JCheckBoxMenuItem(); break; default: item = new JMenuItem(); } item.setText(text); if (image != null) { item.setIcon(image); } if (acceleratorKey > 0) { item.setMnemonic(acceleratorKey); } if (toolTip != null) { item.setToolTipText(toolTip); } item.setActionCommand(command); item.addActionListener(action); menu.add(item); return item; } }