int temp;
counter = 0;
while (counter <= 1000)
{
g.setColor(Color.black);
g.drawRect(0,0,300, 300);
g.setColor(getNewColor(counter % 12));
g.drawString("hello World",xCoord, yCoord);
counter = counter + 1;
temp = xCoord + xChange + 55;
if ( temp >= xRight)
{
xChange = -xChange;
}
temp = xCoord + xChange;
if (temp <= xLeft)
{
xChange = -xChange;
}
temp = yCoord + yChange;
if ( temp >= yBottom)
{
yChange = -yChange;
}
temp = yCoord + yChange;
if (temp <= yTop)
{
yChange = -yChange;
}
xCoord = xCoord + xChange;
yCoord = yCoord + yChange;
for (int count = 0; count < 1000; count++)
{
g.drawString(" ", 0,0);
}
}