Search Here

Java program for creating Concentric Circle


/* Concentric Circle */

import java.awt.*;
import java.applet.*;
import java.awt.Color;

/* 
 <applet code=concentric_circles width=500 height=500>
 </applet> 
*/
  
public class concentric_circles extends Applet
{
 public void paint(Graphics g)
 {
  int i=150,j=150;
  int rval, gval, bval;
  
  while(i>=30)
  {
   // Generating Random Colors
   rval = (int)Math.floor(Math.random() * 256);
   gval = (int)Math.floor(Math.random() * 256);
   bval = (int)Math.floor(Math.random() * 256);
   g.setColor(new Color(rval, gval, bval));
   
   // Drawing Circles
   g.drawOval(i,i,j,j);   
   i = i - 10;
   j = j + 20;
  }
 }
}
 

No comments:

Post a Comment