From 5630c161eac90c99cf9f6b738c752152d338b08b Mon Sep 17 00:00:00 2001 From: Dar Date: Tue, 9 Jan 2024 16:58:21 +0100 Subject: [PATCH] fix: restore the renderer background after hover The table header background is never restored after hover when the label renderer is opaque --- .../main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java index 14a6e16f..5bdc2524 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java @@ -360,6 +360,9 @@ public class FlatTableHeaderUI Icon oldIcon = null; int oldHorizontalTextPosition = -1; + // needed when we have to restore the label background after hover and the renderer is opaque + boolean restoreBackground = false; + // hover and pressed background/foreground TableColumn draggedColumn = header.getDraggedColumn(); Color background = null; @@ -377,6 +380,7 @@ public class FlatTableHeaderUI if( background != null ) { oldBackground = l.getBackground(); oldOpaque = l.isOpaque(); + restoreBackground = true; l.setBackground( FlatUIUtils.deriveColor( background, header.getBackground() ) ); l.setOpaque( true ); } @@ -415,7 +419,7 @@ public class FlatTableHeaderUI } // restore modified renderer component properties - if( oldBackground != null ) + if( restoreBackground ) l.setBackground( oldBackground ); if( oldForeground != null ) l.setForeground( oldForeground );