Java examples for Swing:JFrame
set Frame 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 screen = toolkit.getScreenSize(); int x = screen.width - jf.getWidth() >> 1; int y = screen.height - jf.getHeight() >> 1 - 32; jf.setLocation(x, y);//w w w . j a va 2 s.com } }