本文介绍了如何在java对话框中使字体加粗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
JOptionPane.showMessageDialog(null,+ company1 +
有更高的A市场价值\不到+ company2,
信息,JOptionPane.INFORMATION_MESSAGE);
我想让company1和company2在对话框中显示为粗体。我尝试使用HTML格式,但(我想)显然没有工作。
任何线索或提示?
TIA!
解决方案使用
HTML
JOptionPane.showMessageDialog(null,< html>< b>有< / b>更高的市场价值< / html>);
如果您的默认字体不支持,那么您可以指定它像
String msg =< html>以及如何获得:< ul>< i>< i>斜体< / i>和
+< li>< b>粗体< / b>和
+< li>< u>下划线< / ul>< ; / HTML>中;
JLabel label = new JLabel(msg);
label.setFont(new Font(serif,Font.PLAIN,14));
JOptionPane.showConfirmDialog(null,label);输出:
$ p $输出:
I have this:
JOptionPane.showMessageDialog(null, " " + company1 +
" Has Higher A Market Value\nThan " + company2,
"Information", JOptionPane.INFORMATION_MESSAGE);
I want to make company1 and company2 appear bold in the dialogue box. I tried using html formatting but (I suppose) obviously that did not work.
Any clues or hints?
TIA!
解决方案 Use HTML
JOptionPane.showMessageDialog(null, "<html> <b> Has </b>Higher A Market Value</html> ");
If your default font doesn't support it then you can specify it like
String msg = "<html>This is how to get:<ul><li><i>italics</i> and "
+ "<li><b>bold</b> and "
+ "<li><u>underlined</u>...</ul></html>";
JLabel label = new JLabel(msg);
label.setFont(new Font("serif", Font.PLAIN, 14));
JOptionPane.showConfirmDialog(null, label);
Output:
这篇关于如何在java对话框中使字体加粗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-23 08:42