Java tutorial
//package com.java2s; import javax.swing.SwingUtilities; public class Main { /** * Causes <tt>runnable.run()</tt> to be run in the swing thread after a given delay * @param runnable the task to run in the swing thread * @param delayMillis the delay in milliseconds */ public static void doDelayedInSwing(final Runnable runnable, final long delayMillis) { new Thread(() -> { try { Thread.sleep(delayMillis); SwingUtilities.invokeLater(runnable); } catch (InterruptedException e) { // ignore } }).start(); } }