Java examples for Swing:JDialog
show Center Swing JDialog
//package com.java2s; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JDialog; public class Main { public static void showCenterDialog(JDialog dialog) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screen = toolkit.getScreenSize(); dialog.setBounds((screen.width - dialog.getWidth()) / 2, (screen.height - dialog.getHeight()) / 2, dialog.getWidth(), dialog.getHeight()); dialog.setVisible(true);// ww w.j ava 2s . c om } }