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) { }`
The JOptionPane displays the dialog boxes with one of the four standard icons (question, information, warning, and error) or the custom icons specified by the user.
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));
or
UIManager UI=new UIManager();
UI.put("OptionPane.background", Color.white);
UI.put("Panel.background", Color.white);
JOptionPane.showMessageDialog(null,"Text","SetColor",JOptionPane.INFORMATION_MESSAGE);
Use this code if you have the same problem as erik k atwood. This solves the problem:
UIManager.put("OptionPane.background", Color.WHITE);
UIManager.getLookAndFeelDefaults().put("Panel.background", Color.WHITE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With