timersample.java

来自「The Definitive Guide to Java Swing, Thir」· Java 代码 · 共 21 行

JAVA
21
字号
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

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);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?