TableHeader: restore also renderer foreground after hover

This commit is contained in:
Karl Tauber
2024-01-10 19:19:01 +01:00
parent 5630c161ea
commit 9f17a5b26d

View File

@@ -356,13 +356,10 @@ public class FlatTableHeaderUI
JLabel l = (JLabel) c; JLabel l = (JLabel) c;
Color oldBackground = null; Color oldBackground = null;
Color oldForeground = null; Color oldForeground = null;
Boolean oldOpaque = null; boolean oldOpaque = false;
Icon oldIcon = null; Icon oldIcon = null;
int oldHorizontalTextPosition = -1; 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 // hover and pressed background/foreground
TableColumn draggedColumn = header.getDraggedColumn(); TableColumn draggedColumn = header.getDraggedColumn();
Color background = null; Color background = null;
@@ -380,7 +377,6 @@ public class FlatTableHeaderUI
if( background != null ) { if( background != null ) {
oldBackground = l.getBackground(); oldBackground = l.getBackground();
oldOpaque = l.isOpaque(); oldOpaque = l.isOpaque();
restoreBackground = true;
l.setBackground( FlatUIUtils.deriveColor( background, header.getBackground() ) ); l.setBackground( FlatUIUtils.deriveColor( background, header.getBackground() ) );
l.setOpaque( true ); l.setOpaque( true );
} }
@@ -419,12 +415,12 @@ public class FlatTableHeaderUI
} }
// restore modified renderer component properties // restore modified renderer component properties
if( restoreBackground ) if( background != null ) {
l.setBackground( oldBackground ); l.setBackground( oldBackground );
if( oldForeground != null )
l.setForeground( oldForeground );
if( oldOpaque != null )
l.setOpaque( oldOpaque ); l.setOpaque( oldOpaque );
}
if( foreground != null )
l.setForeground( oldForeground );
if( oldIcon != null ) if( oldIcon != null )
l.setIcon( oldIcon ); l.setIcon( oldIcon );
if( oldHorizontalTextPosition >= 0 ) if( oldHorizontalTextPosition >= 0 )