code: public static void centerOnParent(Window window, Component parent) {
  		if (parent == null || !parent.isShowing()) {
  			// call our own centerOnScreen so we work around bug in
  			// setLocationRelativeTo(null)
  			centerOnScreen(window);
  		}
  		else {
  			window.setLocationRelativeTo(parent);
  		}
  	}
docs: Center the window relative to it's parent. If the parent is null, or not showing,
  the window will be centered on the screen
  
  @param window the window to center
  @param parent the parent