Timer Class : Swing Timer « Swing « Java Tutorial






import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
public class TimerSample {
  public static void main(String args[]) {
    Runnable runner = new Runnable() {
      public void run() {
        ActionListener actionListener = new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("Hello World Timer");
          }
        };
        Timer timer = new Timer(500, actionListener);
        timer.start();
      }
    };
    EventQueue.invokeLater(runner);
  }
}








14.114.Swing Timer
14.114.1.Swing Timers
14.114.2.Timer Properties: coalesce
14.114.3.Timer Class
14.114.4.To turn on log messages
14.114.5.Timer based animation
14.114.6.A rotating and scaling rectangle.
14.114.7.Font size animation
14.114.8.Fade out an image: image gradually get more transparent until it is completely invisible.
14.114.9.Swing Timer actionSwing Timer action