Here you can find the source of getCenterLocation(Window window)
public static Point getCenterLocation(Window window)
//package com.java2s; /*// ww w.ja v a 2 s . c o m * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. */ import java.awt.*; public class Main { public static Point getCenterLocation(Window window) { Dimension componentSize = window.getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Point pos = new Point(); pos.x = ((screenSize.width / 2) - (componentSize.width / 2)); pos.y = ((screenSize.height / 2) - (componentSize.height / 2)) - 30; return pos; } }