CeciliA CeciliA - 2 months ago 5
Java Question

How can I call JFrame with another JFrame after 2 Seconds Delay?

new SplashDemoGUI().setVisible(true);
try {
Thread.sleep(2000);
new sample().setVisible(true);
} catch (InterruptedException ex) {

}


Maybe someone can help me, I`ve put it in public main.

Answer
new java.util.Timer().schedule( 
    new java.util.TimerTask() {
        @Override
        public void run() {
            new sample().setVisible(true);
        }
    }, 
    2000 
);

This should do the job.

EDIT

JFrame hints at Swing, so it seems Swing Timer will be appropriate. – PM 77

Comments