public void jButton1_actionPerformed(ActionEvent e) {
jLabel4.setText("****");
this.repaint();
this.jLabel4.repaint();
this.jLabel4.revalidate();
this.jLabel4.updateUI(); //这些方法都没有用
try{
Thread.sleep(3000);
}catch( Exception ie){
System.out.println("Wrong....from sleep");
}
}做了一个按扭,可是运行时死3秒,然后才更新jLabel4,我现在想在sleep前把jLabel4的文本改了,怎么办?谢谢了!
jLabel4.setText("****");
this.repaint();
this.jLabel4.repaint();
this.jLabel4.revalidate();
this.jLabel4.updateUI(); //这些方法都没有用
try{
Thread.sleep(3000);
}catch( Exception ie){
System.out.println("Wrong....from sleep");
}
}做了一个按扭,可是运行时死3秒,然后才更新jLabel4,我现在想在sleep前把jLabel4的文本改了,怎么办?谢谢了!
mouseup Thread.sleep(3000)
repaint();而repaint()过程是向操作系统发送消息(最终交给本地API来做)你所说的问题根本原因在于——更新事件比线程休眠指令晚到达,从而导致更新滞后
public void jButton1_actionPerformed(ActionEvent e) {
draw();
try{
Thread.sleep(3000);
}catch(Exception ie){
System.out.println("Wrong....from sleep");
}
}
我如何让draw做完以后在Sleep 或者 Wait延时 三秒中? ?