Saturday, March 8, 2014

Indian Flag using java applet

                       




/*How to make indian Flag using applet*/
import java.awt.*;
import java.applet.*;
public class Flag extends Applet
{
public void paint(Graphics g)
{
g.fillOval(60,450,120,50);
g.fillRect(110,60,10,400);
g.setColor(Color.red);
g.fillRect(120,80,150,30);
g.setColor(Color.white);
g.fillRect(120,110,150,30);
g.setColor(Color.green);
g.fillRect(120,140,150,30);
g.setColor(Color.black);
g.drawRect(120,80,150,90);
g.setColor(Color.blue);
g.drawOval(180,110,30,30);
int a=0;
int x=195,y=125;
double x1,y1;
double r=15;
double d;
for(int i=1;i<=24;i++)
{
d=(double)a*3.14/180.0;
x1=x+(double)r*Math.cos(d);
y1=y+(double)r*Math.sin(d);
g.drawLine(x,y,(int)x1,(int)y1);
a+=360/24;
}
}
}
/*<applet code ="Flag" width=1368 height=678></applet>*/



//credits : Priyanandan Alok , KIIT University

No comments: