how to set Jframe for 5 second
问题 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