Saturday, September 6, 2025
HomeLanguagesJavaDraw an Olympic Symbol in Java Applet

Draw an Olympic Symbol in Java Applet

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




// Java program to Draw an Olympic
// Symbol using Java Applet
import java.applet.*;
import java.awt.*;
/*<applet code="Olympics" width=600 height=600>
</applet>*/
 
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: https://www.geeksforgeeks.org/different-ways-to-run-applet-in-java to run applet program.

RELATED ARTICLES

Most Popular

Dominic
32270 POSTS0 COMMENTS
Milvus
82 POSTS0 COMMENTS
Nango Kala
6639 POSTS0 COMMENTS
Nicole Veronica
11803 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11869 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7029 POSTS0 COMMENTS
Thapelo Manthata
6705 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS