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

  2. Program that accepts a shopping list of items from the command line and stores them in a vector. Also provide facility to perform operation

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

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

  5. Program to declare, initialize and print an array of characters

  6. An applet program to display alternate filled and empty circle that to in row and column format

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

  8. An applet program to take user input and display

  9. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

  10. Program to show the use of Logical OR Operator (|) in If Statements

  11. Program to show the use of While Loop

  12. File handling program to copy bytes from one file to another

  13. Program of creating a file using text fields in windows

  14. Program to find a factorial of a given number

  15. corba program of client and a DNS server where given a URL the server sends back an IP address

  16. An applet program to draw circle in center of the canvas

  17. Program to show an example of using initialization block to initialize the data members of a class

  18. Program to show the use of Do-While Loop

  19. Program to print triangle of numbers

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

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