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 |
/* Colored Hello World Applet Example This Java example shows how to create an applet which shows "Hello World" text in different color using Java Applet and Color classes. */ /* Using Colors */ /* Syntax Color(int R, int G, int B) Color(int rgb) Color(float r, float g, float b) */ /* Color Cosntants { black, blue, cyan, darkGray, gray, green, ligntGray, magenta, orange, pink, red, white, yellow} */ import java.applet.Applet; import java.awt.Graphics; import java.awt.Color; /* <applet code = "ColoredHelloWorldExample" width = 300 height = 300> </applet> */ public class ColoredHelloWorldExample extends Applet{ public void paint(Graphics g){ //set color to blue g.setColor(Color.blue); //print hello world g.drawString("Hello World...",30,180); } } |
Add Comment