OptionPane: fixed rendering of longer HTML text if it is passed as StringBuilder, StringBuffer, or any other object that returns HTML text in method toString() (similar to issue #12)

This commit is contained in:
Karl Tauber
2021-09-03 11:20:46 +02:00
parent 51d7bc2c37
commit b25fcc3381
2 changed files with 13 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -162,8 +163,15 @@ public class FlatOptionPaneUI
cons.insets.bottom = UIScale.scale( messagePadding );
// disable line wrapping for HTML
if( msg instanceof String && BasicHTML.isHTMLString( (String) msg ) )
maxll = Integer.MAX_VALUE;
if( msg != null &&
!(msg instanceof Component) &&
!(msg instanceof Object[]) &&
!(msg instanceof Icon) )
{
msg = msg.toString();
if( BasicHTML.isHTMLString( (String) msg ) )
maxll = Integer.MAX_VALUE;
}
// fix right-to-left alignment if super.addMessageComponents() breaks longer lines
// into multiple labels and puts them into a box that aligns them to the left