To simply the question here, for the following code, after mouse clicking, instead of executing the code one line by another, the following happens: 1. program paused for 1 second; 2. GLabel "CLICKED" and GLabel "PAUSE FINISHED" are added to canvas at the same time after the pause.
Could someone explain this for me? Thank you very much.
public void mouseClicked(MouseEvent e){
add(new GLabel("CLICKED"),200,200);
pause(1000);
add(new GLabel("PAUSE FINISHED"),200,300);
}
While this code would work as expected:
public void run(){
add(new GLabel("CLICKED"),20,20);
pause(1000);
add(new GLabel("PAUSE FINISHED"),20,50);
}