Java tutorial
//package com.java2s; //License from project: Apache License import java.awt.BorderLayout; import java.awt.Component; import java.awt.Frame; import javax.swing.JDialog; public class Main { static public JDialog addDialogWindow(Frame mainWindow, Component jpanel, String title) { JDialog dialog = new JDialog(mainWindow, title, true); dialog.getContentPane().setLayout(new BorderLayout()); dialog.getContentPane().add(jpanel, BorderLayout.CENTER); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.pack(); dialog.setLocationRelativeTo(mainWindow); dialog.setSize(jpanel.getPreferredSize()); dialog.setVisible(true); return dialog; } }