如何在 Java/GWT 中经过一段时间后隐藏弹出窗口
可能的重复:
我们如何计算处理时间?
我有一个用户保存值后弹出的弹出对话框。我希望弹出窗口在 2 秒后消失。类似于
if(timeElapsed(2 seconds)){
popup.hide()
}
我看到的相关问题衡量函数的运行时间。如何运行虚拟循环 2 秒,然后调用隐藏函数?
Possible Duplicate:
How can we count the time of process?
I have a pop-up dialog that pops up after a user had saved a value. I want the popup to disappear after 2 seconds. Somthing like
if(timeElapsed(2 seconds)){
popup.hide()
}
The related questions I saw measure the running time of a function. How can I run a dummy loop for 2 seconds and then call the hide function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在弹出面板中定义计时器。接下来,您可以在 show() 方法中初始化计时器,如下所示:
这将在首次显示弹出窗口时启动计时器。当计时器到期时,弹出窗口将被隐藏。
最终,您可以将计时器定义为弹出窗口中的全局变量,并使用布尔值来查看计时器是否正在运行,这样,如果您需要在实例仍在显示时再次显示弹出窗口,则不会启动新的计时器。
You can define a Timer in your popup panel. Next you can init the Timer in the show() method like this:
This will start the timer when the popup is first showed. When the timer expires, the popup will be hidden.
Eventually you can define the timer as a global variable in the popup and use a boolean to see if the timer is running, so that if you need to display the popup again while an instance is still showing, you won't start a new timer.