Java tutorial
//package com.java2s; import java.awt.*; public class Main { /** * centers the frame in the center of the screen * * @param pFrame Frame to center */ static public void centerWindow(Window pFrame) { Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); center.x = center.x - (int) pFrame.getSize().getWidth() / 2; center.y = center.y - (int) pFrame.getSize().getHeight() / 2; pFrame.setLocation(center); } }