Java examples for Swing:JFrame
Display JFrame In Center
//package com.java2s; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JFrame; public class Main { public static void DisplayInCenter(JFrame frame) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); }/*from w w w . j av a2 s . com*/ }