Set JButton background color

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

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


import javax.swing.JButton;
import javax.swing.JFrame;

import java.awt.Color;
import java.awt.FlowLayout;

public class SetJButtonBackgroundColor
{
public static void main(String[]args)
{
//Create button using JButton
JButton button=new JButton("Click me");

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

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//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 JButton background color to color that you choose
button.setBackground(color);

//Add JButton into JFrame
frame.add(button);

//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
**************************************************************************

RELAXING NATURE VIDEO