How to draw a circle in Java?

To draw a circle in Java, call the Graphics.drawOval method inside JFrame.paint.

Here is the smallest amount of code to draw a circle in Java:

import javax.swing.*;
import java.awt.*;

public class DrawCircle extends JFrame {

  public void paint(Graphics graphics) {
    graphics.drawOval(100, 100, 200, 200);

  public static void main(String[] args) {
    DrawCircle frame = new DrawCircle();
    frame.setSize(500, 500);

This program creates a 500x500 window (JFrame), that paints a 200x200 oval inside of itself.