Java tutorial
//package com.java2s; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JFrame; public class Main { public static void centerJFrame(JFrame jFrame) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); int x = (screenSize.width - jFrame.getWidth()) / 2; int y = (screenSize.height - jFrame.getHeight()) / 2; jFrame.setLocation(x, y); } }