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 {
    /**
     * Generic-ified version of SwingUtilities.getAncestorOfClass()
     */
    public static <T> T getAncestorOfClass(Class<T> c, Component comp) {
        if (comp == null || c == null)
            return null;
        Container parent = comp.getParent();
        while (parent != null && !(c.isInstance(parent)))
            parent = parent.getParent();
        return (T) parent;
    }
}