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. An applet program to draw different shapes

  2. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

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

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

  5. Program to show the use of Conditional (Ternary) Operator

  6. Program to show an example of using a recursive method in a class

  7. Program of concatenating and Buffering files

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

  9. GUI application in java, which enter the details of a student and on the submit display the details of the student

  10. Program of binary search tree

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

  12. Program to ask question and accept answer up to 3 attempt and display right answer if it is wrong

  13. Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()

  14. Program to show the use of Conditional OR Operator (||) in If Statements

  15. An applet program to add two numbers where data is entered in TextField

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

  17. Program of Floyds Triangle

  18. RMI application for getting the final total price of the shopping list with some of the following items and quantities chosen by the user

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

  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