Here you can find the source of runTimer(int duration, final Runnable run)
public static void runTimer(int duration, final Runnable run)
//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(); } }