Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (C) 2011 Peransin Nicolas.
 * Use is subject to license terms.
 */

import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.HeadlessException;
import java.awt.Window;
import javax.swing.JDialog;

import javax.swing.SwingUtilities;

public class Main {
    public static JDialog createJDialog(Component parentComponent) throws HeadlessException {
        return createJDialog(parentComponent, null, true);
    }

    public static JDialog createJDialog(Component parentComponent, String title) throws HeadlessException {
        return createJDialog(parentComponent, title, true);
    }

    public static JDialog createJDialog(Component parentComponent, String title, boolean modal)
            throws HeadlessException {

        Window window = SwingUtilities.getWindowAncestor(parentComponent);
        if (window instanceof Frame) {
            return new JDialog((Frame) window, title, modal);
        } else {
            return new JDialog((Dialog) window, title, modal);
        }
    }
}