private boolean isTitleBarCaptionAt( Component c, int x, int y ) {
		if( !c.isDisplayable() || !c.isVisible() || !contains( c, x, y ) || c == mouseLayer )
			return true; // continue checking with next component

		// check enabled component that has mouse listeners
		if( c.isEnabled() &&
			(c.getMouseListeners().length > 0 ||
			 c.getMouseMotionListeners().length > 0) )
		{
			if( !(c instanceof JComponent) )
				return false; // assume that this is not a caption because the component has mouse listeners

			// check client property boolean value
			Object caption = ((JComponent)c).getClientProperty( COMPONENT_TITLE_BAR_CAPTION );
			if( caption instanceof Boolean )
				return (boolean) caption;

			// if component is not fully layouted, do not invoke function
			// because it is too dangerous that the function tries to layout the component,
			// which could cause a dead lock
			if( !c.isValid() ) {
				// revalidate if necessary so that it is valid when invoked again later
				EventQueue.invokeLater( () -> {
					Window w = SwingUtilities.windowForComponent( c );
					if( w != null )
						w.revalidate();
					else
						c.revalidate();
				} );

				return false; // assume that this is not a caption because the component has mouse listeners
			}

			if( caption instanceof Function ) {
				// check client property function value
				@SuppressWarnings( "unchecked" )
				Function<Point, Boolean> hitTest = (Function<Point, Boolean>) caption;
				Boolean result = hitTest.apply( new Point( x, y ) );
				if( result != null )
					return result;
			} else {
				// check component UI
				ComponentUI ui = JavaCompatibility2.getUI( (JComponent) c );
				if( !(ui instanceof TitleBarCaptionHitTest) )
					return false; // assume that this is not a caption because the component has mouse listeners

				Boolean result = ((TitleBarCaptionHitTest)ui).isTitleBarCaptionAt( x, y );
				if( result != null )
					return result;
			}

			// else continue checking children
		}

		// check children
		if( c instanceof Container ) {
			for( Component child : ((Container)c).getComponents() ) {
				if( !isTitleBarCaptionAt( child, x - child.getX(), y - child.getY() ) )
					return false;
			}
		}
		return true;
	}
Returns whether there is a component at the given location, that processes
mouse events. E.g. buttons, menus, etc.
<p>
Note:
<ul>
  <li>This method is invoked often when mouse is moved over window title bar area
      and should therefore return quickly.
  <li>This method is invoked on 'AWT-Windows' thread (not 'AWT-EventQueue' thread)
      while processing Windows messages.
      It <b>must not</b> change any component property or layout because this could cause a dead lock.
</ul>
flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java