Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Java Example Java Swing Set Color in JOptionPane

Related Tutorials


Share on Google+Share on Google+

Set Color in JOptionPane

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.


Here is the code:

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

Download Source Code:



If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 15, 2009

Related Tutorials

Discuss: Set Color in JOptionPane  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
January 10, 2013
set color

what's the use of the UI Manager ?