Program to draw Concentric Circles on Applet
In this program, we have to draw four concentric circles as shown in output. The setFont( ) method is used to set the font in that you have to pass the Font class's object. You have to pass font name, font style and font size in Font's constructor like:
PROGRAM
OUTPUT
C:\>javac ConcentricCircles.java
C:\>appletviewer ConcentricCircles.java
g.setFont(new Font("Times New Roman", Font.BOLD|Font.ITALIC, 14));
PROGRAM
import java.awt.*;
import java.applet.*;
public class ConcentricCircles extends Applet
{
public void paint(Graphics g)
{
g.setFont(new Font("Times New Roman",Font.BOLD|Font.ITALIC,14));
g.drawString("Concentric Circles",30,30);
int i=65,j=65;
while(i>=30)
{
g.drawOval(i,i,j,j);
i = i - 10;
j = j + 20;
}
}
}
/* <applet code=ConcentricCircles width=200 height=200>
</applet> */
OUTPUT
C:\>javac ConcentricCircles.java
C:\>appletviewer ConcentricCircles.java