简体   繁体   English

如何设置Jframe 5秒

[英]how to set Jframe for 5 second

I'm using netbeans 7.1.1, to create a JFrame. 我正在使用netbeans 7.1.1,创建一个JFrame。 I want to automatically dispose the JFrame 5 seconds after calling setVisible() . 我想在调用setVisible()后5秒钟自动处理JFrame How can I do this? 我怎样才能做到这一点?

HINT 暗示

Use Swing Timer to wait for 5 seconds before calling setVisible(false) or dispose() whichever way you want it implemented. 使用Swing Timer等待5秒钟,然后再调用setVisible(false)dispose()无论您希望采用哪种方式实现。 Hidden/Disposed 隐藏/处置

Did u do your research on this? 您是否对此进行了研究? Seems straight forward. 似乎直截了当。

new Timer().schedule(new TimerTask() {
    public void run() {
          // this should be final
          jframe.dispose();
    }
}, 5000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM