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 d8ce988c..c059438c 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
@@ -32,6 +32,8 @@ import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
+import javax.swing.plaf.basic.BasicHTML;
+import javax.swing.text.View;
import com.formdev.flatlaf.FlatLaf;
/**
@@ -85,10 +87,16 @@ public class FlatMenuItemRenderer
}
// text size
- String text = menuItem.getText();
- FontMetrics fm = menuItem.getFontMetrics( menuItem.getFont() );
- width += SwingUtilities.computeStringWidth( fm, text );
- height = Math.max( fm.getHeight(), height );
+ View htmlView = (View) menuItem.getClientProperty( BasicHTML.propertyKey );
+ if( htmlView != null ) {
+ width += htmlView.getPreferredSpan( View.X_AXIS );
+ height = Math.max( (int) htmlView.getPreferredSpan( View.Y_AXIS ), height );
+ } else {
+ String text = menuItem.getText();
+ FontMetrics fm = menuItem.getFontMetrics( menuItem.getFont() );
+ width += SwingUtilities.computeStringWidth( fm, text );
+ height = Math.max( fm.getHeight(), height );
+ }
// accelerator size
String accelText = getAcceleratorText();
@@ -226,6 +234,12 @@ debug*/
}
protected void paintText( Graphics g, Rectangle textRect, String text, Color selectionForeground, Color disabledForeground ) {
+ View htmlView = (View) menuItem.getClientProperty( BasicHTML.propertyKey );
+ if( htmlView != null ) {
+ htmlView.paint( g, textRect );
+ return;
+ }
+
int mnemonicIndex = FlatLaf.isShowMnemonics() ? menuItem.getDisplayedMnemonicIndex() : -1;
paintText( g, menuItem, textRect, text, mnemonicIndex, menuItem.getFont(),
diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.java
index 52d8390a..01293441 100644
--- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.java
+++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.java
@@ -197,7 +197,7 @@ public class FlatMenusTest
panel1.add(checkBoxMenuItemLabel, "cell 0 2");
//---- checkBoxMenuItem1 ----
- checkBoxMenuItem1.setText("enabled");
+ checkBoxMenuItem1.setText("enabled");
checkBoxMenuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
checkBoxMenuItem1.setMnemonic('A');
panel1.add(checkBoxMenuItem1, "cell 1 2");
diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.jfd
index 2700ef0b..e6ee7a88 100644
--- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.jfd
+++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.jfd
@@ -92,7 +92,7 @@ new FormModel {
} )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "checkBoxMenuItem1"
- "text": "enabled"
+ "text": "enabled"
"accelerator": &KeyStroke0 static javax.swing.KeyStroke getKeyStroke( 112, 0, false )
"mnemonic": 65
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {