Java tutorial
//package com.java2s; import java.awt.*; public class Main { public static void centerOnScreen(Component aCompo) { final Dimension lComponentSize = aCompo.getSize(); centerOnScreen(aCompo, lComponentSize); } public static void centerOnScreen(Component aCompo, Dimension aCompoSize) { final Dimension lScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); aCompo.setLocation(lScreenSize.width / 2 - (aCompoSize.width / 2), lScreenSize.height / 2 - (aCompoSize.height / 2)); } }