Code:
@Override
public void mouseReleased(MouseEvent e) { //when the mouse is pressed
Point where=e.getPoint();
int x=(where.x-3)/20+1;
int y=(where.y-30)/20+1;
if(x>=1&&x<=30&&y>=1&&y<=30)
{
v[x][y]=1-v[x][y];
repaint();
try{
TimeUnit.MILLISECONDS.sleep(300);
}
catch(Exception ex){}
redo();
repaint();
}
}
The paint function is made so that it will show, on screen, all 30x30 elements of the V matrix. The redo function makes some changes (the details are irrelevant) to V.
What i am trying to do is paint the elements of V, but with v[x][y] changed, wait 0.3s, and then paint the elements of V again, but this time after they were changed by the redo function. But the repaint only works the second time, the first time not doing anything.