Here you can find the source of findMenu(JMenuBar menuBar, String menuName)
public static JMenu findMenu(JMenuBar menuBar, String menuName)
//package com.java2s; //License from project: Open Source License import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.MenuElement; public class Main { public static JMenu findMenu(JMenuBar menuBar, String menuName) { MenuElement[] menus = menuBar.getSubElements(); for (int ii = 0; ii < menus.length; ++ii) { JMenu menu = (JMenu) menus[ii].getComponent(); if (menu.getText().equals(menuName)) return menu; }// w w w .j ava 2s .c o m return null; } }