Here you can find the source of getJMenuItem(String name, JMenuBar jmenubar)
public static JMenuItem getJMenuItem(String name, JMenuBar jmenubar)
//package com.java2s; //License from project: LGPL import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class Main { public static JMenuItem getJMenuItem(String name, JMenuBar jmenubar) { JMenuItem returnedItem = null; JMenuBar jbar = jmenubar; for (int i = 0; i < jbar.getMenuCount(); i++) { JMenu jmenu = jbar.getMenu(i); for (int j = 0; j < jmenu.getItemCount(); j++) { JMenuItem jitem = jmenu.getItem(j); if (name.equals(jitem.getText())) { returnedItem = jitem; }//from w w w.j av a 2s. c o m } } return returnedItem; } }