Here you can find the source of centerDialog(JDialog dDialog)
Parameter | Description |
---|---|
dDialog | The dialog to center. |
public static void centerDialog(JDialog dDialog)
//package com.java2s; //License from project: Apache License import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JDialog; public class Main { /**//from w w w . ja va 2s. c o m * This method centers the given dialog. * * @param dDialog The dialog to center. */ public static void centerDialog(JDialog dDialog) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension labelSize = dDialog.getSize(); dDialog.setLocation((screenSize.width / 2) - (labelSize.width / 2), (screenSize.height / 2) - (labelSize.height / 2)); } }