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.Dialog;

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