我已经在我的应用程序中添加了JOptionPane,但是我不知道如何将背景颜色更改为白色?
`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
课
import javax.swing.UIManager; UIManager UI=new UIManager(); UI.put("OptionPane.background",new ColorUIResource(255,0)); UI.put("Panel.background",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);