首页 > 解决方案 > 如何让 html 格式显示在 JOptionPane 中?

问题描述

我不明白为什么这不起作用。

String address = "somebody@abc.com";
String htmlText = "<html><br><font color='red'>" + address + "</font></html>";

JOptionPane.showMessageDialog(Component, "My App v0 \n\n" + 
                            "Send questions or comments to: " + htmlText, 
                            "Questions", JOptionPane.INFORMATION_MESSAGE);

消息框中显示的是地址周围的 html 标记...与 htmlText 分配中的完全一样。

我希望只看到应用了 html 格式的地址。

我将所有的 html 和地址放在字符串中,仍然得到相同的结果:

JOptionPane.showMessageDialog(toolbar, "WFM Network Calculator Version 0.6 
   \n\n" + "Send questions or comments to: <html><br><font 
   color='red'>Someone@abc.com</font></html>", 
   "About",JOptionPane.INFORMATION_MESSAGE);

标签: htmljoptionpane

解决方案


推荐阅读