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.setColor(Color.red);
           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.setColor(Color.blue);
           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.setColor(Color.yellow);
           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.setColor(Color.green);
           g.fillOval(x-r4, y-r4, 2*r4, 2*r4);

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

    Related Post:
  1. An applet program to draw Polygon Graph with given data

  2. An applet program that display blinking rectangle

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

  4. Biological Sequence Allignment Using Dynamic Programing

  5. Program to show the use of Break Statement

  6. Program to show the use of For Loop

  7. An applet program that displays random dot

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

  9. Program in CORBA which takes a long sentence from the client (at least 7 words), passes to the server, server separates out each word

  10. File handling program to display directory contents

  11. Program to show the use of Bitwise Operator (^) XOR (Exclusive OR)

  12. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

  13. Program which will read a string and rewrite it in the alphabetical order

  14. Program of an applet to illustrate BarChart

  15. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

  16. Program to extract a portion of a character string and print the extracted string

  17. Program to show the use of While Loop

  18. Program to show an example of using user-defined package in a program

  19. An applet program to perform merge sort

  20. Program to compute the sum of the digits of a given integer number. eg: I/o=4 then O/p=4+3+2+1=10

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