- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    8
- 
        b22
- 
        x86
- 
        windows_7
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-8350877 | 17.0.16-oracle | Alexey Ivanov | P4 | Resolved | Fixed | b01 | 
| JDK-8351514 | 17.0.16 | Goetz Lindenmaier | P4 | Resolved | Fixed | b01 | 
| JDK-8350879 | 11.0.28-oracle | Alexey Ivanov | P4 | Resolved | Fixed | b01 | 
| JDK-8350968 | 8u461 | Alexey Ivanov | P4 | Resolved | Fixed | b01 | 
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.
- backported by
- 
                    JDK-8350877 JOptionPane bungles HTML messages -           
- Resolved
 
-         
- 
                    JDK-8350879 JOptionPane bungles HTML messages -           
- Resolved
 
-         
- 
                    JDK-8350968 JOptionPane bungles HTML messages -           
- Resolved
 
-         
- 
                    JDK-8351514 JOptionPane bungles HTML messages -           
- Resolved
 
-         
- duplicates
- 
                    JDK-5074006 Swing JOptionPane shows </html> tag as a string after newline -           
- Resolved
 
-         
- links to
- 
                     Commit
        openjdk/jdk/91072ee3 Commit
        openjdk/jdk/91072ee3
- 
                     Commit(master)
        openjdk/jdk17u-dev/db834e07 Commit(master)
        openjdk/jdk17u-dev/db834e07
- 
                     Review
        openjdk/jdk/10081 Review
        openjdk/jdk/10081
- 
                     Review(master)
        openjdk/jdk8u-dev/659 Review(master)
        openjdk/jdk8u-dev/659
- 
                     Review(master)
        openjdk/jdk11u-dev/3036 Review(master)
        openjdk/jdk11u-dev/3036
- 
                     Review(master)
        openjdk/jdk17u-dev/3318 Review(master)
        openjdk/jdk17u-dev/3318