Java tutorial
//package com.java2s; //License from project: Open Source License import java.awt.Window; public class Main { public static void centerWindowOnScreen(Window window) { int screenHeight = (int) window.getToolkit().getScreenSize().getHeight(); int screenWidth = (int) window.getToolkit().getScreenSize().getWidth(); int x = (screenWidth - window.getWidth()) / 2; int y = (screenHeight - window.getHeight()) / 2; window.setLocation(x, y); } }