Java Swing UI Thread Event runTimer(int duration, final Runnable run)

Here you can find the source of runTimer(int duration, final Runnable run)

Description

run Timer

License

Open Source License

Declaration

public static void runTimer(int duration, final Runnable run) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Main {
    public static void runTimer(int duration, final Runnable run) {
        Timer t = new Timer(duration, new ActionListener() {
            @Override//ww  w  .ja va  2s.c  o m
            public void actionPerformed(ActionEvent e) {
                run.run();
            }
        });
        t.setRepeats(false);
        t.start();
    }
}

Related

  1. runOnDispatchThread(Runnable runnable)
  2. runOnEDT(final Runnable r)
  3. runOnSwingThread(Runnable doRun)
  4. runOnSwingThread(Runnable run)
  5. runSafe(Runnable runnable)
  6. safeGUIRun(Runnable runnable)
  7. safelyRunBlockingRoutine(Runnable runnable)
  8. safeSwingCall(@Nonnull final Runnable runnable)
  9. saveInvokeAndWait(Runnable run)