如何更改JOptionPane的背景颜色? [英] How to change background color of JOptionPane?
本文介绍了如何更改JOptionPane的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将JOptionPane添加到我的应用程序中,但我不知道如何将背景颜色更改为白色?
I have added JOptionPane to my application but I do not know how to change background color to white?
`int option = JOptionPane.showConfirmDialog(bcfiDownloadPanel,
new Object[]{"Host: " + source, panel},
"Authorization Required",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE
);
if (option == JOptionPane.OK_OPTION) { }`
推荐答案
使用 UIManager
class
By using the UIManager
class
import javax.swing.UIManager;
UIManager UI=new UIManager();
UI.put("OptionPane.background",new ColorUIResource(255,0,0));
UI.put("Panel.background",new ColorUIResource(255,0,0));
或
UIManager UI=new UIManager();
UI.put("OptionPane.background", Color.white);
UI.put("Panel.background", Color.white);
JOptionPane.showMessageDialog(null,"Text","SetColor",JOptionPane.INFORMATION_MESSAGE);
这篇关于如何更改JOptionPane的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文