Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /* 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 = "Applet04" width = 300 height = 300>
- </applet>
- */
- public class Applet04 extends Applet
- {
- public void paint(Graphics g)
- {
- Color c[] = {Color.blue,Color.cyan, Color.darkGray, Color.gray, Color.green, Color.lightGray,
- Color.magenta, Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
- for(int i = 0; i<c.length; i++)
- {
- g.setColor(c[i]);
- g.drawString("Hello World...",10,10 + (i*10));
- }
- }
- }

Post new comment