Java Tutorial

/* <applet code=\"ConcentricCircle\" height=500 width=500>
   </applet> */

 import java.awt.*;
 import java.applet.*;

 public class ConcentricCircle extends Applet
      public void paint(Graphics g){
           Dimension d = getSize();
           int x = d.width/2;
           int y = d.height/2;
           int r1 = (int) ((d.width < d.height) ? 0.4 * d.width : 0.4 * d.height);
           g.fillOval(x-r1, y-r1, 2*r1, 2*r1);

           int r2 = (int) ((d.width < d.height) ? 0.3 * d.width : 0.3 * d.height);
           g.fillOval(x-r2, y-r2, 2*r2, 2*r2);

           int r3 = (int) ((d.width < d.height) ? 0.2 * d.width : 0.2 * d.height);
           g.fillOval(x-r3, y-r3, 2*r3, 2*r3);

           int r4 = (int) ((d.width < d.height) ? 0.1 * d.width : 0.1 * d.height);
           g.fillOval(x-r4, y-r4, 2*r4, 2*r4);

           g.drawString(\"Width   = \"+d.width,10,10);
           g.drawString(\"Height = \"+d.height,10,20);

    Related Post:
  1. Program to show the use of the Continue Statement

  2. Program of date server and client

  3. Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types

  4. Program to delete mth element from an input string

  5. Program to show the use of If-Else Statement

  6. Program to declare and initialize Integer variables and print them on the Standard Output Device

  7. Servlet which takes input from an HTML client page and calculates and outputs the premium amount

  8. Write a class whose objects holds a current value and have a method to add that value, printing the new value

  9. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  10. Program that takes a long sentence and a character from the client and count the occurrence of the character in the sentence at the server side

  11. Program to change characters in a StringBuffer objects and to reverse its contents

  12. Program to Concat Strings

  13. Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks

  14. Program to print some text on the same line using multiple print statements

  15. An applet program of linear sort

  16. Program to declare, initialize and print a StringBuffer object

  17. Program to show an example of Polymorphism

  18. Program to show the use of operator (&lt;&lt;) Shift Left filling with zero from the right

  19. Program to evaluate following investment equation V=P(1+R)^N

  20. Program to show an example of Copying i.e. Clonning Objects

Didn't find what you were looking for? Find more on An applet program to draw concentric circle in center of the canvas