Microsoft Visual J++. Java


- 3


// run

// ,

//

// ,

// -------------------------------------------------------

public void run()

{

while (true)

{

int x, y, width, height;

int rColor, gColor, bColor;

//

//

x = (int)(dimAppWndDimension.width *

Math.random());

y = (int)(dimAppWndDimension.height *

Math.random());

width = (int)(dimAppWndDimension.width *

Math.random()) / 2;

height = (int)(dimAppWndDimension.height *

Math.random()) / 2;

//

//

rColor = (int)(255 * Math.random());

gColor = (int)(255 * Math.random());

bColor = (int)(255 * Math.random());

 

//

//

g.setColor(new Color(rColor, gColor, bColor));

 

//

g.fillRect(x, y, width, height);

 

// 50

try

{

Thread.sleep(50);

}

catch (InterruptedException e)

{

stop();

}

}

}

}

 

// =========================================================

//

// =========================================================

class DrawEllipse extends Thread

{

//

Graphics g;

 

//

Dimension dimAppWndDimension;

 

// -------------------------------------------------------

// DrawEllipse

// DrawEllipse

// -------------------------------------------------------

public DrawEllipse(Applet Appl)

{

g = Appl.getGraphics();

 

//