Here you can find the source of placeInCenter(JFrame frame)
public static void placeInCenter(JFrame frame)
//package com.java2s; /*/* w w w .j ava 2 s .co m*/ * MiscUtil.java * miscellaneous utilities * Copyright (C) 2006 by Institute for Systems Biology, * Seattle, Washington, USA. All rights reserved. * * This source code is distributed under the GNU Lesser * General Public License, the text of which is available at: * http://www.gnu.org/copyleft/lesser.html */ import java.awt.GraphicsConfiguration; import javax.swing.JFrame; public class Main { public static void placeInCenter(JFrame frame) { GraphicsConfiguration gc = frame.getGraphicsConfiguration(); int screenHeight = (int) gc.getBounds().getHeight(); int screenWidth = (int) gc.getBounds().getWidth(); int windowWidth = frame.getWidth(); int windowHeight = frame.getHeight(); frame.setLocation((screenWidth - windowWidth) / 2, (screenHeight - windowHeight) / 2); } }