开发者

How to make font bold in java dialogue box?

开发者 https://www.devze.com 2023-02-05 23:07 出处:网络
I have this: JOptionPane.showMessageDialog(null, \" \" + company1 + \" Has Higher A Market Value\\nThan \" + company2,

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:

How to make font bold in java dialogue box?

0

精彩评论

暂无评论...
验证码 换一张
取 消