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. Dialog Boxes

  2. Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

  3. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object

  4. Program to show an example of searching Strings for subStrings

  5. Program that demonstrates type casting

  6. Develop a CORBA based application for addition of two complex numbers and displaying the result on client side

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

  8. GUI application in java, which enter the details of a student and on the submit display the details of the student

  9. Program to show the use of Labeled Continue Statement

  10. An applet program that creates string dynamically and displays it

  11. Program that accepts a shopping list of five items from the command line and stores them in vector

  12. Program to show the comparing of Strings for equality

  13. Program of an applet to illustrate BarChart

  14. Program using session tracking capability of Servlets, which displays information of current user session by HttpServletRequest object

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

  16. Program to show the use of For Loop

  17. Program to show the use of Labeled Break Statement

  18. Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()

  19. Program to show the use of Switch Statement for the same statement for several different case labels

  20. RMI servlet program to display message

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