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

@@ -17,6 +17,9 @@ FlatLaf Change Log
since FlatLaf 1.3) since FlatLaf 1.3)
- OptionPane: Fixed `OptionPane.sameSizeButtons`, which did not work as expected - OptionPane: Fixed `OptionPane.sameSizeButtons`, which did not work as expected
when setting to `false`. when setting to `false`.
- 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)
- TextField, FormattedTextField, PasswordField and ComboBox: Fixed alignment of - TextField, FormattedTextField, PasswordField and ComboBox: Fixed alignment of
placeholder text in right-to-left component orientation. placeholder text in right-to-left component orientation.

View File

@@ -24,6 +24,7 @@ import java.awt.GridBagConstraints;
import java.awt.Insets; import java.awt.Insets;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -162,8 +163,15 @@ public class FlatOptionPaneUI
cons.insets.bottom = UIScale.scale( messagePadding ); cons.insets.bottom = UIScale.scale( messagePadding );
// disable line wrapping for HTML // disable line wrapping for HTML
if( msg instanceof String && BasicHTML.isHTMLString( (String) msg ) ) if( msg != null &&
maxll = Integer.MAX_VALUE; !(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 // 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 // into multiple labels and puts them into a box that aligns them to the left