首页javajoptionpaneJava Swing - 如何使用HTML在JOptionPane中打断两行或多行的消息

Java Swing - 如何使用HTML在JOptionPane中打断两行或多行的消息

我们想知道如何使用HTML在JOptionPane中打断两行或多行的消息。
import java.awt.BorderLayout;

import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class Main {

  public static void main(String[] args) {
    String pt1 = "<html><body width='";
    String pt2 = "'><h1>Label Width</h1>"
        + "<p>Many Swing components support HTML 3.2 &amp;"
        + " (simple) CSS.  This is a new line.<br><br>"
        + "<p>The body width in this text is set to " + "";
    String pt3 = " pixels." + "";

    JPanel p = new JPanel(new BorderLayout());

    int width = 175;
    String s = pt1 + width + pt2 + width + pt3;

    JOptionPane.showMessageDialog(null, s);
  }
}