1. Java Applets

1.1 Develop an applet that draws a circle. The dimension of the applet should be 500 x 300 pixels. The circle should be centered in the applet and have a radius of 100 pixels. Display your name centered in a circle.( using drawOval() method)

I used JDK version 1.8

CenterCircleName.java
import java.applet.*;
import java.awt.Graphics;
import java.awt.Dimension;
/*
<applet code="CenterCircleName.class" width=300 height=500>
</applet>
*/
public class CenterCircleName extends Applet
{
public void paint(Graphics g)
{
int r=100;
String name="NAME";
Dimension d=getSize();
int x = d.width/2;
int y = d.height/2;
g.drawString("w:"+x+" y:"+y,20,20);
g.drawOval(x-(r/2),y-(r/2),r,r);
int sWidth=g.getFontMetrics().stringWidth(name);
g.drawString(name,x-(sWidth/2),y+(sWidth/4));
}
}

Output

applet that draws a circle

Happy Coding :)