Java tutorial
//package com.java2s; /* * Jitsi, the OpenSource Java VoIP and Instant Messaging client. * * Distributable under LGPL license. * See terms of license at gnu.org. */ import java.awt.*; public class Main { /** * Returns the index of the given component in the given container. * * @param c the Component to look for * @param container the parent container, where this component is added * @return the index of the component in the container or -1 if no such * component is contained in the container */ public static int getComponentIndex(Component c, Container container) { for (int i = 0, count = container.getComponentCount(); i < count; i++) { if (container.getComponent(i).equals(c)) return i; } return -1; } }