Here you can find the source of display(JFrame parent, JInternalFrame dialog)
Parameter | Description |
---|---|
parent | the parent frame. |
dialog | the dialog. |
public static void display(JFrame parent, JInternalFrame dialog)
//package com.java2s; // under the terms of the GNU Lesser General Public License as published import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JLayeredPane; public class Main { /**// w w w .j a v a2 s . c o m * Display a dialog centered within the given frame. * * @param parent the parent frame. * @param dialog the dialog. */ public static void display(JFrame parent, JInternalFrame dialog) { center(parent, dialog); parent.getLayeredPane().add(dialog, JLayeredPane.POPUP_LAYER); dialog.setVisible(true); } /** * Centers the supplied dialog in its parent's bounds. */ public static void center(JFrame parent, JInternalFrame dialog) { Dimension psize = parent.getSize(); Dimension dsize = dialog.getSize(); dialog.setLocation((psize.width - dsize.width) / 2, (psize.height - dsize.height) / 2); } }