Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML rendering problem #12

Closed
lbalazscs opened this issue Oct 18, 2019 · 2 comments
Closed

HTML rendering problem #12

lbalazscs opened this issue Oct 18, 2019 · 2 comments

Comments

@lbalazscs
Copy link

I am using version 0.13 from Maven. The following code illustrates the problem:

public class HTMLProblem {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(HTMLProblem::runOnEDT);
    }

    private static void runOnEDT() {
        try {
//            UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
            UIManager.setLookAndFeel("com.formdev.flatlaf.FlatDarculaLaf");
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }

        String msg = "<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.";
        JOptionPane.showMessageDialog(null, msg);
    }
}

Here's the result, notice how at the end HTML tags are not interpreted anymore:
flatlaf

Here's the correctly rendered result when using Nimbus:
nimbushtml

@DevCharly
Copy link
Collaborator

This is because FlatFaf enables JOptionPane's line wrapping (at 80 characters), which splits the HTML text into multiple JLabels. So it is actually a bug in Swing. Anyway I'll fix it in the next release.

You can workaround the issue by disabling line wrapping:

UIManager.put( "OptionPane.maxCharactersPerLine", 0 );

@JFormDesigner
Copy link
Owner

thanks, fixed in 0.14

DevCharly added a commit that referenced this issue Sep 3, 2021
…tringBuilder`, `StringBuffer`, or any other object that returns HTML text in method `toString()` (similar to issue #12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants