diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java
index ec5dd4ea..f6a27663 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java
@@ -329,6 +329,11 @@ public class FlatButtonUI
}
}
+ @Override
+ public void paint( Graphics g, JComponent c ) {
+ super.paint( FlatLabelUI.createGraphicsHTMLTextYCorrection( g, c ), c );
+ }
+
@Override
protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text ) {
if( isHelpButton( b ) )
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java
index 1b4cc2ed..b26853b2 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java
@@ -30,7 +30,6 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.plaf.basic.BasicLabelUI;
-import javax.swing.text.View;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.util.HiDPIUtils;
import com.formdev.flatlaf.util.UIScale;
@@ -127,10 +126,15 @@ public class FlatLabelUI
BasicHTML.updateRenderer( c, text );
}
+ static Graphics createGraphicsHTMLTextYCorrection( Graphics g, JComponent c ) {
+ return (c.getClientProperty( BasicHTML.propertyKey ) != null)
+ ? HiDPIUtils.createGraphicsTextYCorrection( (Graphics2D) g )
+ : g;
+ }
+
@Override
public void paint( Graphics g, JComponent c ) {
- View v = (View) c.getClientProperty( BasicHTML.propertyKey );
- super.paint( (v != null) ? HiDPIUtils.createGraphicsTextYCorrection( (Graphics2D) g ) : g, c );
+ super.paint( createGraphicsHTMLTextYCorrection( g, c ), c );
}
@Override
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemRenderer.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemRenderer.java
index 064b582f..d1904120 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemRenderer.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemRenderer.java
@@ -40,6 +40,7 @@ import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.util.Graphics2DProxy;
+import com.formdev.flatlaf.util.HiDPIUtils;
/**
* Renderer for menu items.
@@ -360,7 +361,7 @@ debug*/
if( isArmedOrSelected( menuItem ) && selectionForeground != null )
g = new GraphicsProxyWithTextColor( (Graphics2D) g, selectionForeground );
- htmlView.paint( g, textRect );
+ htmlView.paint( HiDPIUtils.createGraphicsTextYCorrection( (Graphics2D) g ), textRect );
}
protected static boolean isArmedOrSelected( JMenuItem menuItem ) {
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatProgressBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatProgressBarUI.java
index 705725fd..4ac1efbd 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatProgressBarUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatProgressBarUI.java
@@ -31,6 +31,7 @@ import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicProgressBarUI;
+import com.formdev.flatlaf.util.HiDPIUtils;
import com.formdev.flatlaf.util.UIScale;
/**
@@ -194,6 +195,11 @@ public class FlatProgressBarUI
}
}
+ @Override
+ protected void paintString( Graphics g, int x, int y, int width, int height, int amountFull, Insets b ) {
+ super.paintString( HiDPIUtils.createGraphicsTextYCorrection( (Graphics2D) g ), x, y, width, height, amountFull, b );
+ }
+
@Override
protected void setAnimationIndex( int newValue ) {
super.setAnimationIndex( newValue );
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java
index ffc2b854..7bde15d2 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java
@@ -153,7 +153,7 @@ public class FlatRadioButtonUI
}
}
- super.paint( g, c );
+ super.paint( FlatLabelUI.createGraphicsHTMLTextYCorrection( g, c ), c );
}
@Override
diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatHtmlTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatHtmlTest.java
index 0c9e2144..f0c4cac7 100644
--- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatHtmlTest.java
+++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatHtmlTest.java
@@ -58,6 +58,34 @@ public class FlatHtmlTest
editorPaneLabel = new JLabel();
textPaneLabel = new JLabel();
toolTipLabel = new JLabel();
+ panel1 = new JPanel();
+ label5 = new JLabel();
+ label6 = new JLabel();
+ label7 = new JLabel();
+ label3 = new JLabel();
+ button1 = new JButton();
+ button2 = new JButton();
+ label11 = new JLabel();
+ toggleButton1 = new JToggleButton();
+ toggleButton2 = new JToggleButton();
+ label12 = new JLabel();
+ checkBox1 = new JCheckBox();
+ checkBox2 = new JCheckBox();
+ label13 = new JLabel();
+ radioButton1 = new JRadioButton();
+ radioButton2 = new JRadioButton();
+ label8 = new JLabel();
+ menu1 = new JMenu();
+ menu2 = new JMenu();
+ label4 = new JLabel();
+ menuItem1 = new JMenuItem();
+ menuItem2 = new JMenuItem();
+ label9 = new JLabel();
+ checkBoxMenuItem1 = new JCheckBoxMenuItem();
+ checkBoxMenuItem2 = new JCheckBoxMenuItem();
+ label10 = new JLabel();
+ radioButtonMenuItem1 = new JRadioButtonMenuItem();
+ radioButtonMenuItem2 = new JRadioButtonMenuItem();
label1 = new JLabel();
scrollPane15 = new JScrollPane();
editorPane1 = new JEditorPane();
@@ -78,6 +106,7 @@ public class FlatHtmlTest
"[fill]" +
"[fill]" +
"[fill]" +
+ "[fill]" +
"[fill]",
// rows
"[]" +
@@ -100,6 +129,145 @@ public class FlatHtmlTest
toolTipLabel.setText("JToolTip:");
add(toolTipLabel, "cell 3 0");
+ //======== panel1 ========
+ {
+ panel1.setLayout(new MigLayout(
+ "insets 0,hidemode 3",
+ // columns
+ "[fill]" +
+ "[fill]" +
+ "[fill]",
+ // rows
+ "[]" +
+ "[]" +
+ "[]" +
+ "[]" +
+ "[]" +
+ "[]" +
+ "[]" +
+ "[]" +
+ "[]"));
+
+ //---- label5 ----
+ label5.setText("JLabel:");
+ panel1.add(label5, "cell 0 0");
+
+ //---- label6 ----
+ label6.setText("Some Bold Text");
+ panel1.add(label6, "cell 1 0");
+
+ //---- label7 ----
+ label7.setText("Some text");
+ panel1.add(label7, "cell 2 0");
+
+ //---- label3 ----
+ label3.setText("JButon:");
+ panel1.add(label3, "cell 0 1");
+
+ //---- button1 ----
+ button1.setText("Some Bold Text");
+ panel1.add(button1, "cell 1 1");
+
+ //---- button2 ----
+ button2.setText("Some text");
+ panel1.add(button2, "cell 2 1");
+
+ //---- label11 ----
+ label11.setText("text");
+ panel1.add(label11, "cell 0 2");
+
+ //---- toggleButton1 ----
+ toggleButton1.setText("Some Bold Text");
+ toggleButton1.setSelected(true);
+ panel1.add(toggleButton1, "cell 1 2");
+
+ //---- toggleButton2 ----
+ toggleButton2.setText("Some text");
+ toggleButton2.setSelected(true);
+ panel1.add(toggleButton2, "cell 2 2");
+
+ //---- label12 ----
+ label12.setText("text");
+ panel1.add(label12, "cell 0 3");
+
+ //---- checkBox1 ----
+ checkBox1.setText("Some Bold Text");
+ panel1.add(checkBox1, "cell 1 3");
+
+ //---- checkBox2 ----
+ checkBox2.setText("Some text");
+ panel1.add(checkBox2, "cell 2 3");
+
+ //---- label13 ----
+ label13.setText("text");
+ panel1.add(label13, "cell 0 4");
+
+ //---- radioButton1 ----
+ radioButton1.setText("Some Bold Text");
+ panel1.add(radioButton1, "cell 1 4");
+
+ //---- radioButton2 ----
+ radioButton2.setText("Some text");
+ panel1.add(radioButton2, "cell 2 4");
+
+ //---- label8 ----
+ label8.setText("JMenu:");
+ panel1.add(label8, "cell 0 5");
+
+ //======== menu1 ========
+ {
+ menu1.setText("Some Bold Text");
+ }
+ panel1.add(menu1, "cell 1 5");
+
+ //======== menu2 ========
+ {
+ menu2.setText("Some text");
+ }
+ panel1.add(menu2, "cell 2 5");
+
+ //---- label4 ----
+ label4.setText("JMenuItem:");
+ panel1.add(label4, "cell 0 6");
+
+ //---- menuItem1 ----
+ menuItem1.setText("Some Bold Text");
+ panel1.add(menuItem1, "cell 1 6");
+
+ //---- menuItem2 ----
+ menuItem2.setText("Some text");
+ panel1.add(menuItem2, "cell 2 6");
+
+ //---- label9 ----
+ label9.setText("JCheckBoxMenuItem:");
+ panel1.add(label9, "cell 0 7");
+
+ //---- checkBoxMenuItem1 ----
+ checkBoxMenuItem1.setText("Some Bold Text");
+ checkBoxMenuItem1.setSelected(true);
+ panel1.add(checkBoxMenuItem1, "cell 1 7");
+
+ //---- checkBoxMenuItem2 ----
+ checkBoxMenuItem2.setText("Some text");
+ checkBoxMenuItem2.setSelected(true);
+ panel1.add(checkBoxMenuItem2, "cell 2 7");
+
+ //---- label10 ----
+ label10.setText("JRadioButtonMenuItem:");
+ panel1.add(label10, "cell 0 8");
+
+ //---- radioButtonMenuItem1 ----
+ radioButtonMenuItem1.setText("Some Bold Text");
+ radioButtonMenuItem1.setSelected(true);
+ panel1.add(radioButtonMenuItem1, "cell 1 8");
+
+ //---- radioButtonMenuItem2 ----
+ radioButtonMenuItem2.setText("Some text");
+ radioButtonMenuItem2.setSelected(true);
+ panel1.add(radioButtonMenuItem2, "cell 2 8");
+ }
+ add(panel1, "cell 4 0 1 3,aligny top,growy 0");
+
//---- label1 ----
label1.setText("HTML
Sample content
text with link
Paragraph
| Col 1 | Col 2 |
|---|---|
| abc | def |
Paragraph
| Col 1 | Col 2 |
|---|---|
| abc | def |