Is there a way to change JOptionPane.showMessageDialog font?

瘦欲@ 提交于 2020-01-15 06:34:05

问题


Is there a way to change the JOptionPane.showMessageDialog font? I'm trying to write code for a message dialog and I need to change the font if it's possible.


回答1:


 JOptionPane jopt = new JOptionPane();
    String result;
    result = "your message";
    JLabel resLabel = new JLabel(result);
    resLabel.setFont(new Font("Monospaced", Font.BOLD, 50));
    jopt.showMessageDialog( null, resLabel, "Results", JOptionPane.PLAIN_MESSAGE );

Create a new label with your custom font and set the jlabel as a component in joptionpane.



来源:https://stackoverflow.com/questions/36898263/is-there-a-way-to-change-joptionpane-showmessagedialog-font

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!