OptionPane: fixed rendering of longer HTML text (#12)

This commit is contained in:
Karl Tauber
2019-10-18 18:41:14 +02:00
parent 0ede8cd5b9
commit ffef71d6db
6 changed files with 10 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ FlatLaf Change Log
- ComboBox: Use small border if used as table editor.
- ToolBar: Disable focusability of buttons in toolbar.
- OptionPane: Fixed rendering of longer HTML text. (issue #12)
- SwingX: Support `JXBusyLabel`, `JXHeader`, `JXHyperlink`,
`JXTaskPaneContainer` and `JXTaskPane`. (issue #8)

View File

@@ -23,6 +23,7 @@ import java.awt.GridBagConstraints;
import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.plaf.basic.BasicOptionPaneUI;
import com.formdev.flatlaf.util.UIScale;
@@ -122,6 +123,10 @@ public class FlatOptionPaneUI
if( messagePadding > 0 )
cons.insets.bottom = UIScale.scale( messagePadding );
// disable line wrapping for HTML
if( msg instanceof String && BasicHTML.isHTMLString( (String) msg ) )
maxll = Integer.MAX_VALUE;
super.addMessageComponents( container, cons, msg, maxll, internallyCreated );
}

View File

@@ -201,7 +201,7 @@ public class FlatOptionPaneTest
//---- warningOptionPane ----
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
warningOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
warningOptionPane.setMessage("Beware of the dog!");
warningOptionPane.setMessage("<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines.");
panel5.add(warningOptionPane, BorderLayout.CENTER);
}
add(panel5, "cell 1 4");

View File

@@ -140,7 +140,7 @@ new FormModel {
name: "warningOptionPane"
"messageType": 2
"optionType": 2
"message": "Beware of the dog!"
"message": "<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines."
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )

View File

@@ -201,7 +201,7 @@ class OptionPanePanel
//---- warningOptionPane ----
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
warningOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
warningOptionPane.setMessage("Beware of the dog!");
warningOptionPane.setMessage("<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines.");
panel5.add(warningOptionPane, BorderLayout.CENTER);
}
panel9.add(panel5, "cell 1 4");

View File

@@ -143,7 +143,7 @@ new FormModel {
name: "warningOptionPane"
"messageType": 2
"optionType": 2
"message": "Beware of the dog!"
"message": "<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines."
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )