//write a program to create a Flag in java using applet?
// Flag.java
import java.applet.*;
import java.awt.*;
public class Flag extends Applet
{
public void paint(Graphics g)
{
g.drawLine(500,640,500,680);
g.drawRect(300,150,500,100);
g.setColor(Color.WHITE);
g.fillRect(300,150,500,100);
g.setColor(Color.BLUE);
g.drawString("Jai Hind Jai Maa Bharat",800,215);
g.drawRect(280,50,20,550);
g.setColor(Color.blue);
g.fillRect(280,50,20,550);
g.drawRect(200,600,200,40);
g.setColor(Color.blue);
g.fillRect(200,600,200,40);
g.drawRect(100,640,400,40);
g.setColor(Color.blue);
g.fillRect(100,640,400,40);
g.drawRect(300,50,500,100);
g.setColor(Color.ORANGE);
g.fillRect(300,50,500,100);
g.drawRect(300,250,500,100);
g.setColor(Color.GREEN);
g.fillRect(300,250,500,100);
g.drawLine(490,200,590,200);
g.setColor(Color.BLUE);
g.drawOval(490,150,100,100);
g.setColor(Color.BLUE);
g.drawLine(540,150,540,250);
g.drawLine(555,150,525,250);
g.drawLine(570,158,510,241);
g.drawLine(578,165,500,230);
g.drawLine(585,175,495,225);
g.drawLine(588,187,492,213) ;
g.drawLine(493,185,587,215);
g.drawLine(500,170,580,230);
g.drawLine(512,160,572,238);
g.drawLine(520,155,565,242);
g.drawLine(530,150,555,250);
}
}
//Flag.html
<html>
<head><title>First applet</title>
</head>
<body>
<applet code="Flag.class" width="100" height="500">
</applet>
</body>
</html>
O/p:----------------------------------------
// Flag.java
import java.applet.*;
import java.awt.*;
public class Flag extends Applet
{
public void paint(Graphics g)
{
g.drawLine(500,640,500,680);
g.drawRect(300,150,500,100);
g.setColor(Color.WHITE);
g.fillRect(300,150,500,100);
g.setColor(Color.BLUE);
g.drawString("Jai Hind Jai Maa Bharat",800,215);
g.drawRect(280,50,20,550);
g.setColor(Color.blue);
g.fillRect(280,50,20,550);
g.drawRect(200,600,200,40);
g.setColor(Color.blue);
g.fillRect(200,600,200,40);
g.drawRect(100,640,400,40);
g.setColor(Color.blue);
g.fillRect(100,640,400,40);
g.drawRect(300,50,500,100);
g.setColor(Color.ORANGE);
g.fillRect(300,50,500,100);
g.drawRect(300,250,500,100);
g.setColor(Color.GREEN);
g.fillRect(300,250,500,100);
g.drawLine(490,200,590,200);
g.setColor(Color.BLUE);
g.drawOval(490,150,100,100);
g.setColor(Color.BLUE);
g.drawLine(540,150,540,250);
g.drawLine(555,150,525,250);
g.drawLine(570,158,510,241);
g.drawLine(578,165,500,230);
g.drawLine(585,175,495,225);
g.drawLine(588,187,492,213) ;
g.drawLine(493,185,587,215);
g.drawLine(500,170,580,230);
g.drawLine(512,160,572,238);
g.drawLine(520,155,565,242);
g.drawLine(530,150,555,250);
}
}
//Flag.html
<html>
<head><title>First applet</title>
</head>
<body>
<applet code="Flag.class" width="100" height="500">
</applet>
</body>
</html>
O/p:----------------------------------------
No comments:
Post a Comment