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 78371eb3..ae629b55 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 @@ -110,14 +110,26 @@ public class FlatLabelUI c.getClientProperty( "html.disable" ) != Boolean.TRUE && needsFontBaseSize( text ) ) { - int headIndex = text.indexOf( "
" ); - // BASE_SIZE rule is parsed in javax.swing.text.html.StyleSheet.addRule() String style = ""; - if( headIndex < 0 ) - style = "" + style + ""; - int insertIndex = headIndex >= 0 ? (headIndex + "".length()) : "".length(); + String lowerText = text.toLowerCase(); + int headIndex; + int styleIndex; + + int insertIndex; + if( (headIndex = lowerText.indexOf( "" )) >= 0 ) { + // there is a tag --> insert after tag + insertIndex = headIndex + "".length(); + } else if( (styleIndex = lowerText.indexOf( "leading red trailing"); panel2.add(label56, "cell 0 8 7 1"); + + //---- label57 ---- + label57.setText("leading red trailing
"); + panel2.add(label57, "cell 0 9 7 1"); } add(panel2, "cell 4 2"); // JFormDesigner - End of component initialization //GEN-END:initComponents diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatHtmlTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatHtmlTest.jfd index 05001e47..7fe5c8a1 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatHtmlTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatHtmlTest.jfd @@ -372,7 +372,7 @@ new FormModel { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3" "$columnConstraints": "[fill]para[fill][fill][fill][fill][fill][fill]" - "$rowConstraints": "[][][][][][]para[]para[][]" + "$rowConstraints": "[][][][][][]para[]para[][][]" } ) { name: "panel2" auxiliary() { @@ -594,6 +594,12 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 8 7 1" } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label57" + "text": "leading red trailing
" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 9 7 1" + } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 4 2" } )