Here you can find the source of SET_FRAME_CENTER(JFrame frame)
public static void SET_FRAME_CENTER(JFrame frame)
//package com.java2s; //License from project: Open Source License import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JFrame; public class Main { public static void SET_FRAME_CENTER(JFrame frame) { Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize()); Dimension windowSize = new Dimension(frame.getPreferredSize()); int wdwLeft = screenSize.width / 2 - windowSize.width / 2; int wdwTop = screenSize.height / 2 - windowSize.height / 2; frame.pack();/* w ww .j a v a2 s . c om*/ frame.setLocation(wdwLeft, wdwTop); } }