Rotating Ganapati Chakra


Ganapati Chakra


1) Copy this code into a notepad and save file with name Chakra.java
2) Compile the program on command prompt: javac Chakra.java 
3) Run using Appletviewer





import java.awt.*;
import java.applet.*;
/*
<applet code=Chakra.class height=220 width=250>
</applet>
 */

public class Chakra extends Applet
 {
   public void paint(Graphics g)
   {
     g.setColor(Color.red);
     g.drawString("Applet Magic by KK",100,10); 
     int x,y,i,a,r,g1,b;
     x=y=20;
     while(true)
      {
      for(i=0,a=20;i<360;i+=45)
       {
        r=(int)(Math.random()*255);
       g1=(int)(Math.random()*255); b=(int)(Math.random()*255);
       g.setColor(new Color(r,g1,b));
       g.fillArc(x,y,200,200,i,a);
for(double j=0;j<5155555;j++); 
      }
   }
}
}

2 comments:

Thanks for visiting my Blog!

Have a Question ? Need Help in College Assignments, Need Code that is not available here? Just leave a comment & get your code instantly.

Tips to Enhance Your Blog