how to set Jframe for 5 second

纵然是瞬间 提交于 2021-02-11 17:52:45

问题


I'm using netbeans 7.1.1, to create a JFrame. I want to automatically dispose the JFrame 5 seconds after calling setVisible() . How can I do this?


回答1:


HINT

Use Swing Timer to wait for 5 seconds before calling setVisible(false) or dispose() whichever way you want it implemented. Hidden/Disposed




回答2:


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);


来源:https://stackoverflow.com/questions/13231185/how-to-set-jframe-for-5-second

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!