Java examples for Swing:JFrame
set JFrame Center
//package com.java2s; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JFrame; public class Main { public static void setFrameCenter(JFrame jf) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension din = toolkit.getScreenSize(); int x = (din.width - jf.getWidth()) / 2; int y = (din.height - jf.getHeight()) / 2 - 32; jf.setLocation(x, y);/*from w w w . j a va 2 s . co m*/ } }