Java JMenuBar getJMenu(JMenuBar menubar, String menuName)

Here you can find the source of getJMenu(JMenuBar menubar, String menuName)

Description

get J Menu

License

Open Source License

Declaration

public final static JMenu getJMenu(JMenuBar menubar, String menuName) 

Method Source Code

//package com.java2s;
/*//from  w w  w  . ja v a2  s . c  om
 *  Copyright 2007, Plutext Pty Ltd.
 *   
 *  This file is part of Docx4all.
    
Docx4all is free software: you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License 
as published by the Free Software Foundation.
    
Docx4all is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License   
along with Docx4all.  If not, see <http://www.gnu.org/licenses/>.
    
 */

import javax.swing.JMenu;
import javax.swing.JMenuBar;

public class Main {
    public final static JMenu getJMenu(JMenuBar menubar, String menuName) {
        JMenu theMenu = null;

        for (int i = 0; i < menubar.getMenuCount(); i++) {
            JMenu m = menubar.getMenu(i);
            //menubar may have components that are not JMenu.
            //Therefore, m may be NULL. See: JMenubar.getMenu()
            if (m != null && m.getName().equals(menuName)) {
                theMenu = m;
                i = menubar.getMenuCount();//break
            }
        }

        return theMenu;
    }
}

Related

  1. findMenu(JMenuBar menuBar, String menuName)
  2. findMenu(JMenuBar menuBar, String menuName, String subMenuName)
  3. findMenu(JMenuBar menuBar, String name, boolean deepSearch)
  4. findMenuComponent( JMenuBar menuBar, String menuName, String menuComponentName, Class componentClass)
  5. findMenuPosition(JMenuBar menuBar, String name)
  6. getJMenuByName(JMenuBar bar, String name)
  7. getMenu(JMenuBar loMenuBar, String psComando)
  8. getMenuItem(JMenuBar menu, String text)
  9. launch(String title, JComponent component, JMenuBar menuBar)