Microsoft Visual J++. Java


- 2


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

// start

//

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

public void start()

{

if (m_Rectangles == null)

{

m_Rectangles = new Thread(this);

m_Rectangles.start();

}

}

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

// start

//

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

public void stop()

{

if (m_Rectangles != null)

{

m_Rectangles.stop();

m_Rectangles = null;

}

}

 

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

// run

// ,

//

// ,

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

public void run()

{

//

Graphics g = getGraphics();

 

//

Dimension dimAppWndDimension = size();

 

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));