1

I'm trying to change the background color of a JOptionPane but this code didnt work.

JOptionPane jOptionPane1 = new JOptionPane( );
jOptionPane1.showMessageDialog(this, "Επιτυχής καταχώρηση");
jOptionPane1.setBackground(Color.white);

But why?

(I understand that JOptionPane is a static method and theres no need to create a new object, and that i can just import the UIManager to get the job done.)

John
  • 81
  • 2
  • 12

1 Answers1

0

This should solve your problem.

JOptionPane op = new JOptionPane("message", JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); 
     op.setOpaque(true);
     op.setBackground(Color.BLACK);
     op.createDialog(this, "Titel").setVisible(true);

If not, you should have a look on this workaround JOptionPane with different background

Community
  • 1
  • 1
Meister96Fels
  • 508
  • 1
  • 8
  • 26