Pages

Set JPanel background color

Source code below will show you, how to set JPanel background color base on RGB. You can get RGB value for your color using "Color picker" at above.

**********************************************************************
COMPLETE SOURCE CODE FOR : SetJPanelBackgroundColor.java
**********************************************************************


import javax.swing.JPanel;
import javax.swing.JFrame;

import java.awt.Color;

public class SetJPanelBackgroundColor
{
public static void main(String[]args)
{
//Create panel using JPanel
JPanel panel=new JPanel();

//Create JFrame with title ( Set JPanel background color )
JFrame frame=new JFrame("Set JPanel background color");

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JPanel background color to color that you choose
panel.setBackground(color);

//Add JPanel into JFrame
frame.add(panel);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(500,300);

//Make JFrame visible
frame.setVisible(true);
}
}


**********************************************************************
JUST COMPILE AND EXECUTE IT
**********************************************************************
Related Posts Plugin for WordPress, Blogger...

I Also Can Create T-Shirt Logo For You