Java JMenuItem getJMenuItem(String name, JMenuBar jmenubar)

Here you can find the source of getJMenuItem(String name, JMenuBar jmenubar)

Description

get J Menu Item

License

LGPL

Declaration

public static JMenuItem getJMenuItem(String name, JMenuBar jmenubar) 

Method Source Code

//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;
    }
}

Related

  1. createMenu(JMenuItem[] items, String name, String description, int mnemonic)
  2. exit(JMenuItem anItem)
  3. getForeground(final BasicMenuItemUI ui, final JMenuItem menuItem)
  4. getIconPlaceholderWidth(final JMenuItem menuItem, final boolean alignTextToMenuIcons)
  5. getInvoker(final JMenuItem menuItem)
  6. getMenuItemParent(JMenuItem menuItem)
  7. getTopLevelMenu(JMenuItem menuitem)
  8. layoutMenuItem(JMenuItem menuItem, FontMetrics fm, String text, FontMetrics fmAccel, String acceleratorText, Icon icon, Icon checkIcon, Icon arrowIcon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewRect, Rectangle iconRect, Rectangle textRect, Rectangle acceleratorRect, Rectangle checkIconRect, Rectangle arrowIconRect, int textIconGap, int menuItemGap)
  9. linkMenuItem(final JMenuItem master, final JMenuItem slave)