Java tutorial
//package com.java2s; import java.awt.Toolkit; import javax.swing.JFrame; public class Main { public static void setFrameCenter(JFrame frame) { int screenWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); int screenHeight = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); frame.setLocation((screenWidth - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2); } }