private static void setupRoundedBorder( Window popupWindow, Component owner, Component contents ) {
		int borderCornerRadius = getBorderCornerRadius( owner, contents );
		float borderWidth = getRoundedBorderWidth( owner, contents );

		// get Swing border color
		Color borderColor;
		if( contents instanceof JComponent ) {
			Border border = ((JComponent)contents).getBorder();
			border = FlatUIUtils.unwrapNonUIResourceBorder( border );

			// get color from border of contents (e.g. JPopupMenu or JToolTip)
			if( border instanceof FlatLineBorder )
				borderColor = ((FlatLineBorder)border).getLineColor();
			else if( border instanceof LineBorder )
				borderColor = ((LineBorder)border).getLineColor();
			else if( border instanceof EmptyBorder )
				borderColor = FlatNativeWindowsLibrary.COLOR_NONE; // do not paint border
			else
				borderColor = null; // use system default color

			// avoid that FlatLineBorder paints the Swing border
			((JComponent)contents).putClientProperty( KEY_POPUP_USES_NATIVE_BORDER, true );
		} else
			borderColor = null; // use system default color

		if( popupWindow.isDisplayable() ) {
			// native window already created
			setupRoundedBorderImpl( popupWindow, borderCornerRadius, borderWidth, borderColor );
		} else {
			// native window not yet created --> add listener to set native border after window creation
			AtomicReference<HierarchyListener> l = new AtomicReference<>();
			l.set( e -> {
				if( e.getID() == HierarchyEvent.HIERARCHY_CHANGED &&
					(e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0 )
				{
					setupRoundedBorderImpl( popupWindow, borderCornerRadius, borderWidth, borderColor );
					popupWindow.removeHierarchyListener( l.get() );
				}
			} );
			popupWindow.addHierarchyListener( l.get() );
		}
	}
Checks whether the owner component returns a tooltip location in
JComponent.getToolTipLocation(MouseEvent).
flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java