How to Draw Ovals &circles in Applet Window in Java


In this example we will show how to draw ovals & circles in an applet window with drawOval method of Graphics class. You may also see how to draw a filled ovals and circles using fillOval method of Graphics class.

Source Code

package com.beginner.examples;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
 
public class DrawExample5 extends Applet{
 
	public void paint(Graphics g){

		setForeground(Color.green);
		
		//this will draw a oval
		g.drawOval(20,20,20,30);
		
		//this will draw a circle
		g.drawOval(40, 40, 20, 20);
        System.out.println("ok");
	}
}

Output:

ok

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments