Java examples for Swing:JFrame
show Center Swing JFrame
//package com.java2s; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JFrame; public class Main { public static void showCenterFrame(JFrame frame) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screen = toolkit.getScreenSize(); frame.setBounds((screen.width - frame.getWidth()) / 2, (screen.height - frame.getHeight()) / 2, frame.getWidth(), frame.getHeight());/* w w w . java 2 s . c o m*/ frame.setVisible(true); } }