Skip to content

Commit

Permalink
TableHeader: restore also renderer foreground after hover
Browse files Browse the repository at this point in the history
  • Loading branch information
DevCharly committed Jan 10, 2024
1 parent 5630c16 commit 9f17a5b
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,10 @@ public void paintComponent( Graphics g, Component c, Container p, int x, int y,
JLabel l = (JLabel) c;
Color oldBackground = null;
Color oldForeground = null;
Boolean oldOpaque = null;
boolean oldOpaque = false;
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;
Expand All @@ -380,7 +377,6 @@ public void paintComponent( Graphics g, Component c, Container p, int x, int y,
if( background != null ) {
oldBackground = l.getBackground();
oldOpaque = l.isOpaque();
restoreBackground = true;
l.setBackground( FlatUIUtils.deriveColor( background, header.getBackground() ) );
l.setOpaque( true );
}
Expand Down Expand Up @@ -419,12 +415,12 @@ public void paintComponent( Graphics g, Component c, Container p, int x, int y,
}

// restore modified renderer component properties
if( restoreBackground )
if( background != null ) {
l.setBackground( oldBackground );
if( oldForeground != null )
l.setForeground( oldForeground );
if( oldOpaque != null )
l.setOpaque( oldOpaque );
}
if( foreground != null )
l.setForeground( oldForeground );
if( oldIcon != null )
l.setIcon( oldIcon );
if( oldHorizontalTextPosition >= 0 )
Expand Down

0 comments on commit 9f17a5b

Please sign in to comment.