Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.*;

public class Main {
    /**
     * Returns the first parent of given component which is an instance of given class.
     */
    public static <T> T getParent(Component aComponent, Class<T> aClass) {
        while (aComponent != null && !aClass.isInstance(aComponent))
            aComponent = aComponent.getParent();
        return (T) aComponent;
    }
}