Java tutorial
//package com.java2s; import java.awt.Window; public class Main { /** * Move the specified window to the center of the screen. Cautious, it may * occupy two different screens if the system has two or more combined * screens. * * @param window * the specified window */ public static void setWindowToScreenCenter(Window window) { int screenWidth = window.getToolkit().getScreenSize().width; int screenHeight = window.getToolkit().getScreenSize().height; window.setLocation(screenWidth / 2 - window.getSize().width / 2, screenHeight / 2 - window.getSize().height / 2); } }