Search Here

Java program for drawing Indian Flag


/* Drawing Indian flag using applet*/

import java.applet.*;
import java.awt.*;
/*
 <applet code=Indian_flag width=400 height=600>
 </applet>
*/
public class Indian_flag extends Applet
{
 public void paint(Graphics g)
 {
  g.setColor(Color.orange);
  g.fillRect(50,50,200,50);
  g.setColor(Color.white);
  g.fillRect(50,100,200,50);
  g.setColor(Color.green);
  g.fillRect(50,150,200,50);
  g.setColor(Color.blue);
  g.drawOval(125,100,50,50);
  
  int t=0;
  int x1=150,y1=125;
  double x2,y2;
  int r=25;
  double d;
  for(int i=0;i<=24;i++)
  {
   d=(double)t*3.14/180.0;
   x2=x1+(double)r*Math.cos(d);
   y2=y1+(double)r*Math.sin(d);
   g.drawLine(x1,y1,(int)x2,(int)y2);
   t=t+(360/24);
  }

  
  g.setColor(Color.black);
  g.fillRect(40,50,10,500);
  g.setColor(Color.black);
  g.fillRect(10,550,70,30);  
 }
}

No comments:

Post a Comment