How to make font bold in java dialogue box?

前端 未结 1 1807
失恋的感觉
失恋的感觉 2020-12-17 18:28

I have this:

JOptionPane.showMessageDialog(null, \" \" + company1 + 
            \" Has Higher A Market Value\\nThan \" + company2,
                \"Informa         


        
相关标签:
1条回答
  • 2020-12-17 19:00

    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:

    alt text

    0 讨论(0)
提交回复
热议问题