Code:
public void paint(Graphics gfx)
{
if (this.gameState == GAME_STATE_RUNNING)
{
this.drawMyStuff();
try
{
wait(WAIT_TIME);
}
catch(InterruptedException e)
{
System.out.println("Something screwed up: " + e);
}
catch(IllegalMonitorStateException e)
{
System.out.println("Something screwed up: " + e);
}
this.repaint();
}
}
I want it to wait long WAIT_TIME milliseconds before the repaint().
To make pause before looping my painting.
When I run this, it generates an exception every single time I repaint()
Specifically, it throws a java.lang.IllegalMonitorStateException every time.
How to fix?








Comment