Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

import java.awt.Frame;

public class Main {
    /**
     * Finds the Frame containing this component, or null if none found.
     * @param component the component to search
     * @return the Frame containing the component
     */
    public static Frame findContainingFrame(Component component) {
        Container container = component.getParent();
        while (container != null && !(container instanceof Frame)) {
            container = container.getParent();
        }
        return (Frame) container;
    }
}