Java Tutorial

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

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

public class Dots extends Applet implements Runnable
{
     int x=0,y=0;
     Thread t;
     Dimension d;

     public void init(){
         t=new Thread(this);
         t.start();
    }

    public void run(){
        while(true){
         try{
           repaint();

           //Sleep before displaying next dots
            Thread.sleep(10);
           }
          catch(Exception e) {}
         }
    }

    public void update(Graphics g){
         paint(g);
    }

    public void paint(Graphics g){
            d=getSize();
           x = (int) (Math.random() * d.getWidth());
           y = (int) (Math.random() *  d.getHeight());         
              g.fillRect(x,y,10,10);
    }

}

    Related Post:
  1. Simple Applet which will show life cycle of an Applet

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

  3. Program to show the use of Nested If-Else Statements

  4. Program for Thread Priority

  5. Program of reading and writing primitive data

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

  7. Program to convert the given temperature in faherenhiet to celsius using the following conversion formula C= F- 32/1.8

  8. Program to show an example of Arrays of String

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

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

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

  12. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

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

  14. An applet program that displays random dot

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

  16. Program to delete mth element from an input string

  17. Program to show the use of Labeled Break Statement

  18. RMI program of count server and client

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

  20. Program to declare and initialize Boolean variables and print them on the Standard Output Device

 
 
Didn't find what you were looking for? Find more on An applet program that displays random dot