Java JMenu containsMenuComponent(JMenu parent, Component comp)

Here you can find the source of containsMenuComponent(JMenu parent, Component comp)

Description

contains Menu Component

License

BSD License

Declaration

public static boolean containsMenuComponent(JMenu parent, Component comp) 

Method Source Code

//package com.java2s;
/**// w w w. j  a va  2s. c  o m
 * Copyright (c) 2014, by the Authors: John E Lloyd (UBC)
 *
 * This software is freely available under a 2-clause BSD license. Please see
 * the LICENSE file in the ArtiSynth distribution directory for details.
 */

import java.awt.Component;

import javax.swing.JMenu;

public class Main {
    public static boolean containsMenuComponent(JMenu parent, Component comp) {
        return indexOfMenuComponent(parent, comp) != -1;
    }

    public static int indexOfMenuComponent(JMenu parent, Component comp) {
        Component[] comps = parent.getMenuComponents();
        for (int i = 0; i < comps.length; i++) {
            if (comps[i] == comp) {
                return i;

            }
        }
        return -1;
    }
}

Related

  1. addSeparatorIfNeeded(JMenu menu)
  2. applyDefaultProperties(final JMenu comp)
  3. assignMnemonics(JMenu menu)
  4. changeMenuItemsState(final JMenu menu, final boolean enableState)
  5. constructRecentlyFilesMenuItems(JMenu recentlyOpenFilesMenuItem, LinkedHashMap filesOpenedLHM)
  6. countCheckBoxMenuItem(JMenu menu)
  7. createMenu(String menuText, JMenu menu, ActionListener listener)
  8. createMenuBar(JMenu... menues)
  9. createMenuItem(JMenu parent, String text)