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 wo开发者_运维知识库rk.
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:
精彩评论