How to Use HSB to Create Custom Colors in Java


In this example, we could learn how to create a custom color using hue, Saturation , and Brightness (HSB) 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 CustomColorUseHSBExample {

	
	public static void main(String[] args) {
	
		//Custom color
		Color customColor = Color.getHSBColor(0.0f, 1.0f,1.0f);
		
		//Create a frame to set the background to a custom color
		final Frame frame = new Frame("Show color");
		frame.setBounds(200,200,200,200);
		frame.setBackground(customColor);
		
		frame.setVisible(true);
		

	}

}

Output:

![](Output.png)

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments