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 getOwnerFrame(Component component) {
        if (component instanceof Frame) {
            return (Frame) component;
        }
        Container parent = component.getParent();
        while (!(parent instanceof Frame)) {
            parent = parent.getParent();
            if (parent == null) {
                throw new IllegalArgumentException("Component has no root Frame.");
            }
        }
        return (Frame) parent;
    }
}