Here you can find the source of addMenuItem(JMenu menu, Action action)
public static JMenuItem addMenuItem(JMenu menu, Action action)
//package com.java2s; //License from project: Open Source License import javax.swing.Action; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.KeyStroke; public class Main { public static JMenuItem addMenuItem(JMenu menu, Action action) { JMenuItem item = menu.add(action); configureMenuItem(item, action); return item; }//from ww w . j ava2 s. c o m public static JMenuItem addMenuItem(JPopupMenu menu, Action action) { JMenuItem item = menu.add(action); configureMenuItem(item, action); return item; } private static void configureMenuItem(JMenuItem item, Action action) { KeyStroke keystroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY); if (keystroke != null) { item.setAccelerator(keystroke); } item.setIcon(null); item.setToolTipText(null); } }