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 {
    public static Frame findParentFrame(Component component) {
        if (component == null) {
            throw new NullPointerException("component == null");
        }
        Container parent = component.getParent();
        while (parent != null) {
            if ((parent instanceof Frame)) {
                return (Frame) parent;
            }
            parent = parent.getParent();
        }
        return null;
    }
}