gpt4 book ai didi

java - 如何使用showconfirmdialog更改字体?

转载 作者:行者123 更新时间:2023-12-02 06:05:37 25 4
gpt4 key购买 nike

我尝试了很多不同的教程,但没有一个有效,这就是我所拥有的。有什么帮助吗?

UIManager.put("OptionPane.font", new FontUIResource(new Font("Press Start 2P", Font.PLAIN, 11)));

if (questionNumber == questions.size()) {
triviagui.questionFrame.setVisible(false);
JOptionPane.showMessageDialog(null, "Your score for this level was : " + levelScore + " out of 10. \n Your total score is " + triviagui.totalScore, "Scores", JOptionPane.INFORMATION_MESSAGE, pokeballIcon);
}

最佳答案

这就是我在 JLabel 中更改字体的方法,所以也许有帮助?

message = new JLabel(textMessage);

// create bigger text (to-times-bigger)
Font f = message.getFont();
message.setFont(new Font(f.getName(), Font.PLAIN, f.getSize()*2));
// put text in middle of vertical space
message.setVerticalTextPosition(JLabel.CENTER);

您只需从标签中获取字体,然后根据需要重置字体即可。也许你可以用 JDialog 做同样的事情?

<小时/>

我在这里找到了一个有效的答案:formatting text in jdialog box

这可能是按钮的 actionListener 调用的方法:

public void openPopUp(){
String t = "<html>The quick <font color=#A62A2A>brown</font> fox.";
JOptionPane.showMessageDialog(null, t);
}

给你这个结果: enter image description here

关于java - 如何使用showconfirmdialog更改字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22303203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com