@Override
		public void paintComponent( Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate ) {
			if( !(c instanceof JLabel) ) {
				super.paintComponent( g, c, p, x, y, w, h, shouldValidate );
				return;
			}

			JLabel l = (JLabel) c;
			Color oldBackground = null;
			Color oldForeground = null;
			boolean oldOpaque = false;
			Icon oldIcon = null;
			int oldHorizontalTextPosition = -1;

			// hover and pressed background/foreground
			TableColumn draggedColumn = header.getDraggedColumn();
			Color background = null;
			Color foreground = null;
			if( draggedColumn != null &&
				header.getTable().convertColumnIndexToView( draggedColumn.getModelIndex() )
					== getColumn( x - header.getDraggedDistance(), w ) )
			{
				background = pressedBackground;
				foreground = pressedForeground;
			} else if( getRolloverColumn() >= 0 && getRolloverColumn() == getColumn( x, w ) ) {
				background = hoverBackground;
				foreground = hoverForeground;
			}
			if( background != null ) {
				oldBackground = l.getBackground();
				oldOpaque = l.isOpaque();
				l.setBackground( FlatUIUtils.deriveColor( background, header.getBackground() ) );
				l.setOpaque( true );
			}
			if( foreground != null ) {
				oldForeground = l.getForeground();
				l.setForeground( FlatUIUtils.deriveColor( foreground, header.getForeground() ) );
			}

			// sort icon position
			Icon icon = l.getIcon();
			boolean isSortIcon = (icon != null && (icon == ascendingSortIcon || icon == descendingSortIcon));
			if( isSortIcon ) {
				if( sortIconPosition == SwingConstants.LEFT ) {
					// left
					oldHorizontalTextPosition = l.getHorizontalTextPosition();
					l.setHorizontalTextPosition( SwingConstants.RIGHT );
				} else if( sortIconPosition == SwingConstants.TOP || sortIconPosition == SwingConstants.BOTTOM ) {
					// top or bottom
					oldIcon = icon;
					l.setIcon( null );
				}
			}

			// paint renderer component
			super.paintComponent( g, c, p, x, y, w, h, shouldValidate );

			// paint top or bottom sort icon
			if( isSortIcon && (sortIconPosition == SwingConstants.TOP || sortIconPosition == SwingConstants.BOTTOM) ) {
				int xi = x + ((w - icon.getIconWidth()) / 2);
				int yi = (sortIconPosition == SwingConstants.TOP)
					? y + UIScale.scale( 1 )
					: y + height - icon.getIconHeight()
						- 1 // for gap
						- (int) (1 * UIScale.getUserScaleFactor()); // for bottom border
				icon.paintIcon( c, g, xi, yi );
			}

			// restore modified renderer component properties
			if( background != null ) {
				l.setBackground( oldBackground );
				l.setOpaque( oldOpaque );
			}
			if( foreground != null )
				l.setForeground( oldForeground );
			if( oldIcon != null )
				l.setIcon( oldIcon );
			if( oldHorizontalTextPosition >= 0 )
				l.setHorizontalTextPosition( oldHorizontalTextPosition );
		}
Cell renderer pane that is used to paint hover and pressed background/foreground
and to paint sort arrows at top, bottom or left position.
flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java