本文介绍了有没有办法更改JOptionPane.showMessageDialog字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改JOptionPane.showMessageDialog字体?我正在尝试为消息对话框编写代码,并且如果可能的话,我需要更改字体.

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.

推荐答案

 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 );

使用自定义字体创建新标签,并将jlabel设置为joptionpane中的组件.

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

这篇关于有没有办法更改JOptionPane.showMessageDialog字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 23:42