Java tutorial
//package com.java2s; import java.awt.*; public class Main { public static final int getComponentIndex(Component component) { if (component != null && component.getParent() != null) { Container currentComponent = component.getParent(); for (int index = 0; index < currentComponent.getComponentCount(); index++) { if (currentComponent.getComponent(index) == component) return index; } } return -1; } }