Home Java Example Java Swing Set Color in JOptionPane



Set Color in JOptionPane
Posted on: October 15, 2009 at 12:00 AM
In this section, you will learn how to set color in JOptionPane.

Set Color in JOptionPane

     

In this section, you will learn how to set color in JOptionPane. Now to do this, we have used UIManager class which is responsible for look and feel. Using following key value pair, we have set the background color for JOptionPane and Panel.

um.put("OptionPane.background",Color.yellow);
um.put("Panel.background",Color.yellow);

Here is the code:

import java.awt.*;
import javax.swing.*;
public class SetColor{
public static void main(String[]args){
 UIManager um=new UIManager();
 um.put("OptionPane.background",Color.yellow);
 um.put("Panel.background",Color.red);
 JOptionPane.showMessageDialog(null,"Hello","Set Color",
   JOptionPane.INFORMATION_MESSAGE
);
}
}

Download Source Code:

 

Related Tags for Set Color in JOptionPane:
cclassuiairiosedcolorbackgroundkeyvaluepanelusingthisaisetooformanagertoroundoptionebackuseimmaninnopairasmjoptionpanejclesagepanackdowhichsspeeespcolpanekisirhallmanagefollowandwingvauimanagerssthavalufendonolonp


More Tutorials from this section

Ask Questions?    Discuss: Set Color in JOptionPane  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.