Java Tutorial

 
 
 
 
/* <applet code=\"altCircle\" height=400 width=300> 
   </applet> */

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

  public class altCircle extends Applet
  {
         public void paint(Graphics g){
             Dimension d = getSize();
             int circleHeight = 50;
             int circleWidth = 50;

             //To bring circle in the center of the canvas
             int x = (d.width/2) - (circleHeight/2);  

             for (int i=0;i<5;i++ )
             {
                     if (i%2 == 0)
                     {
                             g.setColor(Color.green);
                             g.drawOval(x,i*60 + 10, circleWidth,circleHeight);
                     }
                     else
                     {
                            g.setColor(Color.red);
                             g.fillOval(x,i*60 + 10, circleWidth,circleHeight);
                     }
             }
        }
  }[/Code]

    Related Post:
  1. Program to declare and initialize Integer variables and print them on the Standard Output Device

  2. Program sets up a String variable containing a paragraph of text of your choice. Extract the words from the text and sort them into alphabetical order

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

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

  5. Program to read command line arguments

  6. Socket program of multi client chat server

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

  8. Program to show the use of operator (&gt;&gt;) Shift Right, propagating the sign bit from the left

  9. Program that reads and writes random access file

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

  11. Corba program of game

  12. Even number ,Prime no. ,Factorial of a number

  13. Program to show an example of extraction of characters from a StringBuffer objects

  14. Program to show the use of Increment and Decrement Operators

  15. Program to show the use of Bitwise Operator (|) OR

  16. Program of concatenating and Buffering files

  17. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  18. Program that demonstrates type casting

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

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

 
 
Didn't find what you were looking for? Find more on Program of an applet to display alternate filled and empty circle