⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 《Java2图形设计卷II:Swing》配套光盘源码
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test implements ActionListener {
	private int seconds=1;

	public Test() {
		Timer oneSecondTimer = new Timer(1000, this);

		oneSecondTimer.addActionListener(new SecondListener());
		oneSecondTimer.addActionListener(new ThirdListener());
		oneSecondTimer.start();
	}
	public void actionPerformed(ActionEvent e) {
		if(seconds == 0)
			System.out.println("Time:  " + seconds + " second");
		else
			System.out.println("Time:  " + seconds + " seconds");
		seconds++;
	}
	public static void main(String args[]) {
		new Test();
		while(true);
	}
}
class SecondListener implements ActionListener { 
	public void actionPerformed(ActionEvent e) {
		System.out.println("Second Listener");
	}
}
class ThirdListener implements ActionListener { 
	public void actionPerformed(ActionEvent e) {
		System.out.println("Third Listener");
	}
}

⌨️ 快捷键说明

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