instruction apparently not executed
On clicking my test button, I should see "first message" displayed, then, after a 3 second delay, "second message" displayed. Here's my code:
Code:
private class TestButtonWatcher implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
messagesBox.setText("first message");
delay(3000);
messagesBox.setText("second message");
}
}
private void delay(int interval)
{
try {Thread.sleep(interval);}
catch(InterruptedException e) {System.exit(0);}
}
BUT: on clicking, "first message" is NOT displayed; there is a 3 second delay and then "second message" IS displayed.
Any help appreciated; thanks.