Thread.sleep() always pauses JFrame before the sleep() statement even gets executed. I have the following method to pause the thread:
private void sleep(int milli) {
try {
Thread.sleep(milli);
} catch (InterruptedException ex) {
writeToConsoleError("Interrupted");
}
}
I'm calling it in the following switch-case statement under case CARDNOMATCH:, this method is in a class which extends JFrame.
public void handlePacket(Packet recieved) {
int cmd = recieved.getCommand();
int arg1 = -99;
int arg2 = -99;
switch (cmd) {
case CARDNOMATCH:
arg1 = recieved.getFirstArg();
arg2 = recieved.getSecondArg();
if(arg1 > 9) {
arg1 = 9;
}
if(arg2 > 9) {
arg2 = 9;
}
flipCard(choice1, arg1);
flipCard(choice2, arg2);
sleep(3000);
flipCard(choice1, 10);
flipCard(choice2, 10);
break;
case ENABLE_TURN:
this.isTurn = true;
break;
case DISABLE_TURN:
this.isTurn = false;
break;
}
}
Please, anyone, give me some insight :(