Java tutorial
//package com.java2s; import java.awt.*; public class Main { public static int getIndex(Container parent, Component child) { for (int i = 0; i < parent.getComponentCount(); i++) { if (child.equals(parent.getComponent(i))) return i; } return -1; } }