Draw an Olympic Symbol in Java Applet
Last Updated :
08 Mar, 2024
Given task is to draw an Olympic symbol in Java Applet.
Expected Output:
 Â
Approach: Use drawOval() method to draw a circle with x and y coordinates and length and breadth.
Below is the implementation of the above approach:Â
Applet Program:Â
Java
import java.applet.*;
import java.awt.*;
public class Olympics extends Applet {
public void paint(Graphics g)
{
g.setColor(Color.BLUE);
g.drawOval( 30 , 30 , 30 , 30 );
g.setColor(Color.YELLOW);
g.drawOval( 50 , 45 , 30 , 30 );
g.setColor(Color.BLACK);
g.drawOval( 70 , 30 , 30 , 30 );
g.setColor(Color.GREEN);
g.drawOval( 90 , 45 , 30 , 30 );
g.setColor(Color.RED);
g.drawOval( 110 , 30 , 30 , 30 );
}
}
|
Output:
Note: To run the applet in command line use the following commands
> javac Olympics.java
> appletviewer Olympics.java
You can also refer to: Different ways to run applet program.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...