private static void ensureOnScreen( JFrame frame ) {
		Rectangle frameBounds = frame.getBounds();
		boolean onScreen = false;
		for( GraphicsDevice screen : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices() ) {
			GraphicsConfiguration gc = screen.getDefaultConfiguration();
			Rectangle screenBounds = FlatUIUtils.subtractInsets( gc.getBounds(),
				Toolkit.getDefaultToolkit().getScreenInsets( gc ) );
			if( frameBounds.intersects( screenBounds ) ) {
				onScreen = true;
				break;
			}
		}

		if( !onScreen )
			frame.setLocationRelativeTo( null );
	}
Creates a UI defaults inspector panel that can be embedded into any window.
flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatUIDefaultsInspector.java