Here you can find the source of getViewMenu(JFrame mainFrame)
private static JMenu getViewMenu(JFrame mainFrame)
//package com.java2s; //License from project: Open Source License import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.MenuElement; public class Main { private static final String MENU_NAME = "Window"; private static JMenu getViewMenu(JFrame mainFrame) { JMenuBar menuBar = mainFrame.getJMenuBar(); MenuElement[] menuElements = menuBar.getSubElements(); for (MenuElement menuElement : menuElements) { if (menuElement instanceof JMenu) { JMenu menu = (JMenu) menuElement; String name = menu.getText(); if (name.equalsIgnoreCase(MENU_NAME)) { return menu; }/* w w w. ja v a 2 s . c o m*/ } } return null; } }