Here you can find the source of centerFrameOnScreen(JFrame frame)
public static void centerFrameOnScreen(JFrame frame)
//package com.java2s; //License from project: Open Source License import java.awt.*; import javax.swing.*; public class Main { /**//from www . j av a 2 s . com * Centers a {@link JFrame} on screen. */ public static void centerFrameOnScreen(JFrame frame) { final Dimension position = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((position.width - frame.getWidth()) / 2, (position.height - frame.getHeight()) / 2); } }