关于程序中暂停的问题,thread.sleep无法正常工作,求指点。。急用

自己在写一个简单浏览器程序,大体已经实现,想添加一个安全模块,就是账号管理,在设置账号过程中,有各种问题,都已经解决,就最后一个问题,当出现 输入密码 和 确认密码不同的时候,我想账户界面窗口显示栏先显示两次输入不同,再将确定按钮设置为无法使用,接着让程序暂停5s。。。。。。。。。在清空提示信息(即两次输入不同)和输入栏内所有输入,再使确认按钮可以使用,我自己代码如下,运行时每次一点确定按钮,程序立刻暂停,5s后才显示错误信息,怎么样才能让程序正常显示,求指点。。。相关代码如下: comfirm为确认密码的JpasswordFieldd类对象 password为输入密码的JpasswordField对象 bok为确定按钮对象 pscp为错误信息显示窗口。

  else if(change(comfirm.getPassword())!= change(password.getPassword())) {
pscp.setText("error:两次输入不同");
bok.setEnabled(false);
// System.out.println(3);
// try{
Thread.currentThread().sleep(4000);
  }catch(Exception e3)
  {
  }
 
  //System.out.println(change(password.getPassword()));
// System.out.println(change(comfirm.getPassword()));
 
password.setText(null);
comfirm.setText(null);
bok.setEnabled(true);

}

作者: friseasky   发布时间: 2011-06-06

引用楼主 friseasky 的回复:

接着让程序暂停5s



你的这种效果应该在页面上做的吧?
你在后台做根本没用,只能让页面加载返回结果时延迟加载而已。

应该在页面用js设置"确认按钮"为disable.
用setInterval("yourfunction(){设置"确认按钮"为enable.}",5000);

作者: dryZeng   发布时间: 2011-06-07