Hello World in different colors - Coder's point

Monday, March 25, 2019

Hello World in different colors

 import java.applet.Applet;  
 import java.awt.Graphics;  
 import java.awt.Color;  
 /*   
 <applet code = "HelloWorldInDifferentColorsExample.class" width = 300 height = 300>  
 </applet>  
  */  
 public class HelloWorldInDifferentColorsExample 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));  
     }  
   }  
 }  
OUTPUT:

No comments:

Post a Comment