Here you can find the source of centerWindow(JFrame frame)
public static void centerWindow(JFrame frame)
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { public static void centerWindow(JFrame frame) { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); int screenHeight = screenSize.height; int screenWidth = screenSize.width; frame.setLocation(screenWidth / 4, screenHeight / 4); }// w w w .j av a 2s. com }