Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;
import java.awt.Container;

public class Main {
    public static final int getComponentIndex(final Component component) {
        if (component != null && component.getParent() != null) {
            final Container c = component.getParent();
            for (int i = 0; i < c.getComponentCount(); i++) {
                if (c.getComponent(i) == component) {
                    return i;
                }
            }
        }
        return -1;
    }
}