Here you can find the source of getCenterCoordinates(Dimension d)
public static Point getCenterCoordinates(Dimension d)
//package com.java2s; import java.awt.Dimension; import java.awt.Point; import java.awt.Toolkit; public class Main { /**/*from w w w . j av a2 s .c o m*/ * @return the coordinates for the upper-left corner of you window * so that it is centered */ public static Point getCenterCoordinates(Dimension d) { Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); Point ul = new Point(); ul.x = (s.width - d.width) / 2; ul.y = (s.height - d.height) / 2; return (ul); } }