Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Container;

public class Main {
    static public <T extends Container> T findAncestorOfType(Container acomp, Class<T> type) {
        Container parent = acomp;
        while (parent != null) {
            if (type.isInstance(parent))
                return type.cast(parent);
            parent = parent.getParent();
        }
        return null;
    }
}