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 |
/* Create Custom Color Using RGB Example This java example shows how to create a custom color using red, green and blue (RGB) components in an Applet window using Java AWT Color class. */ import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; /* <applet code="CreateCustomColor" width=200 height=100> </applet> */ public class CreateCustomColor extends Applet{ public void paint(Graphics g) { /* * To create a custom color using RGB, use * Color(int red,int green, int blue) * constructor of Color class. */ //this will create light blue color Color customColor = new Color(10,10,255); //set foreground color of an applet this.setForeground(customColor); g.drawString("This is a custom RGB color", 10, 50); } } |
Example Output
Add Comment