static Window centerWindow(Component c) { Window w = getWindow(c); if (w != null) w.setLocationRelativeTo(null); // magic trick ret w; } static Window centerWindow(Component c, int width, int height) { setWindowSize(c, width, height); ret centerWindow(c); } static JWindow centerWindow(JWindow w) { centerWindow(getRootPane(w)); ret w; }