Need time waster code or something.



I'm trying to "flash" a button, by changing its icon from one color to another.

It works with the mouse events (on when clicked, off when released), but when I try to run the following code, I don't see a change. I see something happen to the button (the color square gets ever so slightly smaller), but the color doesn't change. If I comment out the code where it sets the color back off, it stays on, so I know its executing.

I'm assuming my for-loop wait mechanism is the problem, and might be going by so fast I can't see it. I've tried larger numbers and the same problem.

Is there a better wait mechanism?


public void flashButton()
{
button.setIcon(onIcon);
for (long i = 0; i < 1000000; i++)
{

}
button.setIcon(offIcon);
}
.