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:
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



Comments

Popular posts from this blog

Develop an Android application to display “Hello World!” on screen

Program to design an applet which draws a circle (having color BLUE) inside a triangle (having color YELLOW)

Build a Simple Android App to Display Student Details