更改大小e字体joptionpane [英] change size e font joptionpane

查看:238
本文介绍了更改大小e字体joptionpane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你可以改变JOptionPane文本的字体和大小?我试过了,只有当我在该特定的类java上运行文件时,它才能正常工作。如果你启动整个项目不改变字体。我只会改变一个特定的JOptionPane而不是所有的

这里是代码

  UIManager.put(OptionPane.messageFont,new FontUIResource(new Font(
Arial,Font.BOLD,18)));
JOptionPane.showMessageDialog(null,MESSAGE,ERROR,JOptionPane.WARNING_MESSAGE);

谢谢

解决方案

真的很简单。 JOption窗格不仅接受字符串,还接受组件。所以你可以创建一个标签来设置它的字体,并将其作为消息。


label.setFont(new Font(Arial,Font.BOLD,18));
JOptionPane.showMessageDialog(null,label,ERROR,JOptionPane.WARNING_MESSAGE);

我不明白为什么没有人回答这个问题。

you can change the font and size of the text of a JOptionPane? I tried it and it works only if I "run file" on that specific class java. if you start the whole project does not change the font. I would change only a specific JOptionPane not all

here is the code

 UIManager.put("OptionPane.messageFont", new FontUIResource(new Font(  
          "Arial", Font.BOLD, 18)));       
 JOptionPane.showMessageDialog(null,"MESSAGE","ERROR",JOptionPane.WARNING_MESSAGE);       

thank you

解决方案

It's really easy. JOption pane accepts not only strings but also components. So you can create a label set its font and use it as message.

JLabel label = new JLabel("MESSAGE");
label.setFont(new Font("Arial", Font.BOLD, 18));
JOptionPane.showMessageDialog(null,label,"ERROR",JOptionPane.WARNING_MESSAGE);

I don't understand why nobody answered this question before

这篇关于更改大小e字体joptionpane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆