Here you can find the source of findMenuItem(JMenu menu, String menuItemName)
public static JMenuItem findMenuItem(JMenu menu, String menuItemName)
//package com.java2s; //License from project: Open Source License import javax.swing.JMenu; import javax.swing.JMenuItem; public class Main { public static JMenuItem findMenuItem(JMenu menu, String menuItemName) { if (menu.getItemCount() > 0) { for (int ii = 0; ii < menu.getItemCount(); ++ii) { JMenuItem menuItem = menu.getItem(ii); if (menuItem.getText().equals(menuItemName)) return menuItem; }/*from w ww . j a v a2s . c o m*/ } return null; } }