我想知道如何在Java中使用Swing应用程序添加时间延迟,我使用过Thread.sleep(time),但我也使用了SwingWorker,但它不起作用.这是我的代码的一部分:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
我希望你在使用SwingWorker时可以帮助我或解决我的疑虑.