Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import java.awt.Component;

public class Main {
    public static <T extends Component> T findParentComponentOfType(Component component, Class<T> type) {
        do {
            component = component.getParent();
            if (component != null && type.isAssignableFrom(component.getClass())) {
                return (T) component;
            }
        } while (component != null);

        return null;
    }
}