import java.awt.*;
public class RelativeToNull {
    public static void main(String args[]) throws Exception {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        Point centerPoint = ge.getCenterPoint();

        Frame f = new Frame ("ParentFrame");
        f.setSize(200, 200);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
        try { Thread.sleep(3000); } catch (Exception e) {}

        Point pt = f.getLocationOnScreen();
        int expectedX = centerPoint.x - f.getWidth() / 2;
        int expectedY = centerPoint.y - f.getHeight() / 2;
        System.out.println("expected center: "+expectedX+", "+expectedY);
        System.out.println("  actual center: "+pt.x+", "+pt.y);
    }

}
