C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » Java programs » Java swing/awt programs

Java program to draw a circle

In this java program, we are going to learn how to draw a circle using 'Shape' class? Here, we are using 'java.awt.*' related packages, classes to draw a circle.
Submitted by IncludeHelp, on November 19, 2017

By using java program, we have to draw a circle.

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class DrawCircle extends Frame 
	// input the value for circle and square.
	Shape circle=new Ellipse2D.Float(100.0f,100.0f,100.0f,100.0f);
	// class paint to fill color in circle.
	public void paint(Graphics g)
		Graphics2D ga=(Graphics2D)g;
	public static void main(String args[])
		// create a frame object for circle.
		Frame frame=new DrawCircle();
		frame.addWindowListener(new WindowAdapter()
			public void windowClosing(WindowEvent we)
		// circle coordinates.
		frame.setSize(300, 250);


draw a circle using java

Here is the list of other latest and category wise java programs.

Liked this article? Do share with your friends :)