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 which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

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

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

  4. Program that enabled applet calculator

  5. Program to display triangle of numbers

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

  7. Program to read command line arguments

  8. Program to show the use of some Math Methods

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

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

  11. Develop a RMI based application for addition of two complex numbers

  12. Program which simulate the dictionary in java

  13. Program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7

  14. Simple Applet which will show life cycle of an Applet

  15. RMI based application for login validation based on data saved in text file stored on the server and will display appropriate message to the client..

  16. Program to generate Fibonacci Series of a given number

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

  18. An applet program of showing new document using showDocument(URL) method

  19. CORBA program for displaying the date and time of the server machine, client machine and the difference between these two date and time

  20. Program to read the table elements into a two-dimensional array temperature

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