Java JDialog Create createJDialog(Component parentComponent)

Here you can find the source of createJDialog(Component parentComponent)

Description

create J Dialog

License

Open Source License

Declaration

public static JDialog createJDialog(Component parentComponent) throws HeadlessException 

Method Source Code


//package com.java2s;
/*/*from  ww  w . j  a v a  2 s . c  om*/
 * 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);
        }
    }
}

Related

  1. createDialogForPanel(JDialog parent, JPanel panel)
  2. createPackedJDialog( java.awt.Component content, java.awt.Component ownerComponent, String title, boolean isModal, int closeOperation)