Java tutorial
//package com.java2s; import java.awt.*; public class Main { public static void setLocationRelativeTo(Window child, Window parent) { Dimension d = parent.getSize(); Dimension u = child.getSize(); child.setLocation((int) ((d.getWidth() / 2) - (u.getWidth() / 2)), (int) ((d.getHeight() / 2) - (u.getHeight() / 2))); } }