Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8042134

JOptionPane bungles HTML messages

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • 8
    • client-libs
    • b22
    • x86
    • windows_7

        FULL PRODUCT VERSION :


        A DESCRIPTION OF THE PROBLEM :
        Because a plain JLabel does not do line breaks, JOptionPane splits multiline strings across multiple JLabels. This breaks HTML messages.

        In this example, line 1 of the message has correct underline formatting; but line 2 has three problems: (1) it has no underline; (2) it is split onto a third line even though \n should be insignificant whitespace in this HTML; (3) it displays the `</u>` literally:

            import javax.swing.*;
            
            class Test {
                public static void main(String... args) {
                    SwingUtilities.invokeLater(() -> {
                        JOptionPane.showMessageDialog(null, "<html><u>line 1<br>\nline\n2</u>");
                    });
                }
            }

        Workaround/fix: Use a single JLabel for HTML messages:

            JOptionPane.showMessageDialog(null, new JLabel("<html><u>line 1<br>\nline\n2</u>"));



        REPRODUCIBILITY :
        This bug can be reproduced always.

              psadhukhan Prasanta Sadhukhan
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: