private Popup getPopupForScreenOfOwner( Component owner, Component contents, int x, int y, boolean forceHeavyWeight )
		throws IllegalArgumentException
	{
		int count = 0;

		for(;;) {
			// create new or get cached popup
			Popup popup = forceHeavyWeight
				? getHeavyWeightPopup( owner, contents, x, y )
				: super.getPopup( owner, contents, x, y );

			// get heavy weight popup window; is null for non-heavy weight popup
			Window popupWindow = SwingUtilities.windowForComponent( contents );

			// check whether heavy weight popup window is on same screen as owner component
			if( popupWindow == null ||
				owner == null ||
				popupWindow.getGraphicsConfiguration() == owner.getGraphicsConfiguration() )
			  return popup;

			// avoid endless loop (should newer happen; PopupFactory cache size is 5)
			if( ++count > 10 )
				return popup;

			// remove contents component from popup window
			if( popupWindow instanceof JWindow )
				((JWindow)popupWindow).getContentPane().removeAll();

			// dispose unused popup
			// (do not invoke popup.hide() because this would cache the popup window)
			popupWindow.dispose();
		}
	}
Creates a popup for the screen that the owner component is on.
<p>
PopupFactory caches heavy weight popup windows and reuses them.
On a dual screen setup, if the popup owner has moved from one screen to the other one,
then the cached heavy weight popup window may be connected to the wrong screen.
If the two screens use different scaling factors, then the popup location and size
is scaled when the popup becomes visible, which shows the popup in the wrong location
(or on wrong screen). The re-scaling is done in WWindowPeer.setBounds() (Java 9+).
<p>
To fix this, dispose popup windows that are on wrong screen and get new popup.
<p>
This is a workaround for https://bugs.openjdk.java.net/browse/JDK-8224608
flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java