HTML: fixed rendering of <hr noshade> in dark themes (issue #932)

This commit is contained in:
Karl Tauber
2025-03-08 19:30:14 +01:00
parent f7495a0a5b
commit 681c0cd4fe
3 changed files with 18 additions and 1 deletions

View File

@@ -62,6 +62,7 @@ FlatLaf Change Log
- Fixed loading FlatLaf UI delegate classes when using FlatLaf in special
application where multiple class loaders are involved. E.g. in Eclipse plugin
or in LibreOffice extension. (issues #955 and #851)
- HTML: Fixed rendering of `<hr noshade>` in dark themes. (issue #932)
#### Incompatibilities

View File

@@ -21,7 +21,7 @@ import java.util.function.BiPredicate;
/**
* @author Karl Tauber
*/
class StackUtils
public class StackUtils
{
private static final StackUtils INSTANCE = new StackUtilsImpl();

View File

@@ -16,6 +16,7 @@
package com.formdev.flatlaf.util;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
@@ -27,7 +28,9 @@ import java.awt.geom.Rectangle2D;
import java.text.AttributedCharacterIterator;
import javax.swing.JComponent;
import javax.swing.RepaintManager;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.FlatSystemProperties;
import com.formdev.flatlaf.ui.StackUtils;
/**
* @author Karl Tauber
@@ -323,6 +326,19 @@ public class HiDPIUtils
public void drawGlyphVector( GlyphVector g, float x, float y ) {
super.drawGlyphVector( g, x, y + yCorrection );
}
@Override
public void fillRect( int x, int y, int width, int height ) {
// fix hard coded black color in HRuleView.paint() of '<hr noshade>'
if( super.getColor() == Color.black &&
StackUtils.wasInvokedFrom( "javax.swing.text.html.HRuleView", "paint", 4 ) )
{
super.setColor( FlatLaf.isLafDark() ? Color.lightGray : Color.darkGray );
super.fillRect( x, y, width, height );
super.setColor( Color.black );
} else
super.fillRect( x, y, width, height );
}
};
}