Here you can find the source of calculatePosition(Window parent, JDialog dialog)
public static Point calculatePosition(Window parent, JDialog dialog)
//package com.java2s; //License from project: Open Source License import java.awt.Point; import java.awt.Window; import javax.swing.JDialog; public class Main { public static Point calculatePosition(Window parent, JDialog dialog) { int x = parent.getX() + (parent.getWidth() - dialog.getWidth()) / 2; int y = parent.getY() + (parent.getHeight() - dialog.getHeight()) / 2; Point p = new Point(x, y); return p; }// w ww . j ava 2s. c om }