answersLogoWhite

0


Best Answer

import java.io.*;

import java.applet.*;

import java.awt.*;

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 t=0;

int x=195,y=125;

double x1,y1;

double r=15;

double d;

for(int i=1;i<=24;i++)

{

d=(double)t*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);

t+=360/24;

}

}

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Java applet program to draw national flag?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a java code to draw a circle inside in an ellipse?

write a program draw circle and ellipse by using oval methods in java


What does Java 2 Runtime Environment SE v1.4.1 01java do?

This softwear peovides an environment for JAVA. When you are using some function on web to establish something, you need it. For example, when I was using "ISI WEB OF KNOWLEDGE", I wank to know the relationship amond the article and other articles who cite it. I press the button "Creat Citation Alert" . Then I need a JAVA program to help me draw out the picture. If I don't have that "Runtime Environment" the JAVA program won't run. I'm not going to get the picture.


Is it possible to write a C plus plus or java program to draw an activity flow diagram given the sequence as a text file input and store the diagram in an output file?

Yes, this is possible.


C program to Draw a line chart?

draw a line chart.


Java program to simulate a car?

import java.awt.*; import java.util.*; import java.applet.*; /* &lt;APPLET CODE="Animation.JAVA" WIDTH=400 HEIGHT=300&gt; &lt;/APPLET&gt; */ //The basic applet class.The applet shows 4 cars crossing each other at a square. public class Animation extends Applet implements Runnable { Thread t; //4 variables used to vary the car's positions. int x1=0,x2=380,y1=50,y2=250; public void start() { if(t==null) { t=new Thread(this,"New Thread");//New side Thread created on start of applet. t.start(); } } public void stop() { if(t!=null) { t=null;//On stop of applet the created thread is destroyed. } } //Implementation of method run() of Runnable interface. public void run() { Thread t1=Thread.currentThread(); while(t==t1) { repaint(); try { Thread.sleep(100); } catch(Exception e) { } } } public void paint(Graphics g) { setBackground(Color.cyan); g.setColor(Color.BLACK); x1=(x1+16)%400; x2=x2-16; y1=(y1+12)%300; y2=y2-12; if(y2&lt;0) y2=288; if(x2&lt;0) x2=384; //Draw the roads using 2 filled rectangles using black color. g.fillRect(0,130,400,40); g.fillRect(180,0,40,305); //Draw the white colored lines. g.setColor(Color.white); for(int i=0;i&lt;20;i++) { if(i!=9 &amp;&amp; i!=10) g.drawLine(i*20,150,i*20+10,150); } for(int j=0;j&lt;15;j++) { if(j!=7 &amp;&amp; j!=8) g.drawLine(200,j*20,200,j*20+10); } //Draw 4 colored cars using filled round rectangles. g.setColor(Color.red); g.fillRoundRect(x2,152,20,8,2,2); g.fillRoundRect(x1,140,20,8,2,2); g.fillRoundRect(190,y1,8,20,2,2); g.fillRoundRect(202,y2,8,20,2,2); } }

Related questions

Java Applet Program to Draw National Flag of azad kashmir?

nothing done worry


Is it possible to draw in java without using applet?

Yes it is possible to draw in java by using AWT package. or by using javax package.


What is applet in javahow it works?

Applets allow you to do frontend in java. You can draw things like rectangle,circle etc or create buttons and textboxes or you could even create a game! You can make use of the powerful api of java to design the applet and make use of awk(abstract window kit).


Write a java code to draw a circle inside in an ellipse?

write a program draw circle and ellipse by using oval methods in java


What does Java 2 Runtime Environment SE v1.4.1 01java do?

This softwear peovides an environment for JAVA. When you are using some function on web to establish something, you need it. For example, when I was using "ISI WEB OF KNOWLEDGE", I wank to know the relationship amond the article and other articles who cite it. I press the button "Creat Citation Alert" . Then I need a JAVA program to help me draw out the picture. If I don't have that "Runtime Environment" the JAVA program won't run. I'm not going to get the picture.


What does custom aim draw and program have in common?

Custom program Aim and draw have in common


Is it possible to write a C plus plus or java program to draw an activity flow diagram given the sequence as a text file input and store the diagram in an output file?

Yes, this is possible.


What word does custom aim draw and program have in common?

Custom program Aim and draw have in common


What can you do with a drawing program?

you can draw on it


Which website can you draw in?

Please see related link below. Note: Uses Java.


C program to Draw a line chart?

draw a line chart.


What is Microsoft Paint?

Microsoft paint is a software program that you draw in.