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. Program to print a string on Standard Output Device

  2. Program to declare, initialize and print a 2D array of integers

  3. Corba program of reverse string

  4. Program to display attributes of a specified file

  5. Program to delete mth element from an input string

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

  7. Program to show an example of modifying String objects

  8. File handling program to copy characters from one file to another

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

  10. Program to show the use of some Math Methods

  11. Program using Switch case to compute the net amount to be paid by a customer

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

  13. Do the following for the Array Insert the element in the array,delete an element from the array,search for a particular element Create multiple thread

  14. RMI based application, which reads a file with list of marks of student from a client, send it to server and find how many students having distinct

  15. Define an array of ten String elements each containing an arbitrary string of the form “month/day/year”

  16. Program to show the use of If-Else Statement

  17. Program which calls the method sort(int []a) which throws the Exception ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException

  18. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  19. An applet program of passing parameters

  20. Program to change characters in a StringBuffer objects and to reverse its contents

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