📄 test.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test implements ActionListener {
private boolean firstRing = true;
private int ring = 1;
public Test() {
Timer.setLogTimers(true);
Timer oneSecondTimer = new Timer(1000, this);
// comment out the following line for colaescing
oneSecondTimer.setCoalesce(false);
System.out.println("Timer is coalescing: " +
oneSecondTimer.isCoalesce());
oneSecondTimer.start();
}
public void actionPerformed(ActionEvent e) {
System.out.println("ring #" + ring++);
if(firstRing) {
// simulate a time consuming operation by sleeping
// for 10 seconds ...
try {
Thread.currentThread().sleep(10000);
}
catch(InterruptedException ex) {
ex.printStackTrace();
}
firstRing = false;
}
}
public static void main(String args[]) {
new Test();
while(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -