How to Customize Color of RGB in Java


In this example, we will learn how to create a custom color using red, green and blue (RGB) components in an Applet window with java AWT Color class.

Source Code

package com.beginner.examples;

import java.awt.Color;
import java.awt.Frame;

public class CustomColorExamples {

	public static void main(String[] args) {

		// Create a frame to display colors
		Frame frame = new Frame("Show Color");
		frame.setBounds(200, 200, 300, 200);

		// Custom color
		Color customColor = new Color(255, 100, 125);
		
		// Sets the frame background to a custom color
		frame.setBackground(customColor);
		
		//Make it visible
		frame.setVisible(true);

	}

}

Output:

![](Output.png)

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments