I'd like to know how to add a time delay inside a Swing app in Java, I used Thread.sleep(time)
, and also I used SwingWorker but it doesn't work. Here's part of my code:
switch (state) {
case 'A':
if (charAux == 'A') {
state = 'B';
//Here's where I'd like to add a time delay
jLabel13.setForeground(Color.red);
break;
} else {
//Here's where I'd like to add a time delay
jLabel12.setForeground(Color.red);
break;
}
}
I hope you could help me or solve my doubts when I'm using SwingWorker.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…