Here you can find the source of getCenteredLocation(Window w)
public static Point getCenteredLocation(Window w)
//package com.java2s; import java.awt.*; public class Main { public static Point getCenteredLocation(Window w) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); int x = d.width - (d.width / 2 + w.getWidth() / 2); int y = d.height - (d.height / 2 + w.getHeight() / 2); Point p = new Point(x, y); return p; }//from w ww . j av a 2s .c o m }