Timer Sample : Timer « Swing JFC « Java






Timer Sample

Timer Sample
 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.Timer;

public class TimerSample {
  public static void main(String args[]) {
    new JFrame().setVisible(true);
    ActionListener actionListener = new ActionListener() {
      public void actionPerformed(ActionEvent actionEvent) {
        System.out.println("Hello World Timer");
      }
    };
    Timer timer = new Timer(500, actionListener);
    timer.start();
  }
}

           
         
  








Related examples in the same category

1.Timer: clock labelTimer: clock label
2.Timer with ProgressBar
3.Tick Tock with an Inner Class
4.Tick Tock with a Static Inner Class
5.Swing Timer Demo
6.Time Resolution
7.An applet that counts down from a specified time
8.Using swing TimerUsing swing Timer