Java examples for Swing:Screen
center Window On Screen
//package com.java2s; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; public class Main { public static void centerWindowOnScreen(Window window) { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); window.setLocation(// w w w.j a v a 2 s. c om (int) (screenSize.getWidth() / 2 - window.getWidth() / 2), (int) (screenSize.getHeight() / 2 - window.getHeight() / 2)); } }