Here you can find the source of containsMenuComponent(JMenu parent, Component comp)
public static boolean containsMenuComponent(JMenu parent, Component comp)
//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; } }