/*
Create Custom Color Using HSB Example
This java example shows how to create a custom color using hue, Saturation
, and Brightness (HSB) components in an Applet window
using Java AWT Color class.
*/
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
/*
<applet code="CreateCustomColorUsingHSB" width=200 height=100>
</applet>
*/
public class CreateCustomColorUsingHSB extends Applet{
public void paint(Graphics g) {
/*
* To create a custom color using HSB, use
* static Color getHSBColor(int hue,int saturation, int brightness)
* method of Color class.
*/
//this will create light blue color
Color customColor = Color.getHSBColor(0.9f,0.5f,0.8f);
//set foreground color of an applet
this.setForeground(customColor);
g.drawString("This is a custom HSB color", 10, 50);
}
}
Example Output

Bookmark/Search this post with: