Tuesday, 29 November 2016

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));

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;
   i = i - 10;
   j = j + 20;

/* <applet code=ConcentricCircles width=200 height=200>
  </applet> */


C:\>javac ConcentricCircles.java
C:\>appletviewer ConcentricCircles.java

No comments:

Post a comment