Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.4K Development
- 17 Developer Projects
- 139 Programming Languages
- 293.1K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 161 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 475 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Applet Starts with a Mouse Click: Why?

Hi,
I have downloaded a program from internet. Its a applet creating Polygons and then moving them by changing their coordinates. I have modified it by using a Time Delay loop instead of built-in Thread function. Its running fine. But I have to right click the mouse to start its execution.
/*
* Program: ArrayFive.java
* Purpose: Using for loop; drawPolygon() & random()
* Author: George Aroush
* Date: 1/1/1998
* Change Log: None
*
* Full description of Program:
* Mutation demo -- randomly displacing points in array
* and demo of drawPolygon() method and demonstrates
* "for ()" loop & the "+=" to move a shape on the
* screen
*/
public class RandomPolygons extends java.applet.Applet
{
final int ONE_SEC = 1000;
final int HALF_SEC = ONE_SEC / 2;
final int NUM_PTS = 7;
final int NUM_MOVES = 20;
public void paint(java.awt.Graphics g)
{
int x[] = { 100, 110, 110, 150, 150, 100, 100 };
int y[] = { 50, 50, 110, 110, 130, 130, 50 };
int count = 0;
g.drawPolygon(x, y, NUM_PTS); /* draw polygon using x[] & y[] array for 7 vertices */
//Sleep(100000000);//Delay(ONE_SEC * 4);
Sleep(1000);
for (count = 0; count < NUM_MOVES; count++) /* draw 20 times */
{
g.clearRect(0, 0, 640, 480); /* clear screen before each display */
g.drawPolygon(x, y, NUM_PTS); /* draw polygon using x[] & y[] array for 7 vertices */
Mutate(x, y, NUM_PTS, 7);
Sleep(100000000);
}
}
/*
* void Mutate()
*
* Randomly moves each x and y in the two arrays by a random integer between 0 and range
*/
public void Mutate(int x[], int y[], int n, int range)
{
int p; /* indexes the arrays */
for (p = 0; p < n; p++) /* mutate the locations of the 7 vertices */
{
x[p] += Random(range); /* each x[] moves from 0 to range pixel, right */
y[p] += Random(range); /* each y[] moves from 0 to range pixels, down */
}
x[n-1] = x[0]; /* make sure the last vertex is the same as */
y[n-1] = y[0]; /* the first, so the outline will be closed */
}
/*
* int Rand()
*
* Generate a random number between 0 to range - 1
*/
public int Random(int range)
{
return ((int) (Math.random() * range));
}
static void Sleep(long val)
{
int i;
int junk;
junk = 0;
i = 0;
while (i < val)
{
junk = junk + i * junk;
i++;
}
}
}
Some body please guide me why i need this mouse click?
Zulfi.