1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/* 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
Add Comment