Search code examples
javaswingbackgroundjoptionpane

changing the background of JOptionPane


I change the background of JOptionPane with this code :

 UIManager.put("OptionPane.background",new ColorUIResource(204, 255, 255));

but the result doesn't look like what I expect

The result.


Solution

  • UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    UIManager.put("OptionPane.background", Color.BLUE);
    UIManager.put("Panel.background", Color.BLUE);
    JOptionPane.showConfirmDialog(null, "YOUR INFORMATION HERE");