create a new thread in your Applet
解决方案 »
- JTable问题
- 请教一下classpath问题(不要灌水,说说自己的理解)
- Java数据库
- 有没有类似 MSDN 的 Java 帮助文档。
- util.Date类中的getYear(),getMonth()多Deprecated了,那我如何达到这两个函数的效果?
- (初学者提问,勿笑话)怎么把我的java程序编译成2进制代码?
- 请问如何获取用户自定义的环境变量值?
- 请问application (or applet)如何实现对applet 小程序的调用??
- 有没有像vb中的format函数,可以把一个日期或时间如9:10:3转换成09:10:03 ?
- jdbc 递归无限极tree
- 如何实现声音的采集、网络传输
- JAVA的好书
import java.util.*; // Calendar class public class TimerTest implements Timeable {
public static void main(String[] args) {
TimerTest me = new TimerTest();
Timer ticker = new Timer(me, 1000);
ticker.cont();
System.out.println("Timer started");
}
public void tick(Timer t) {
System.out.println
("\007Being ticked " + Calendar.getInstance().getTime());
}
}
The Timer class is now part of the Swing package. The Timer object will send an ActionEvent to the registered ActionListener. import javax.swing.Timer;
import java.awt.event.*;
import java.util.*;public class TimerDemo implements ActionListener {
Timer t = new Timer(1000,this); TimerDemo() {
t.start();
} public static void main(String args[]) {
TimerDemo td = new TimerDemo();
// create a dummy frame to keep the JVM running
// (for demonstation purpose)
java.awt.Frame dummy = new java.awt.Frame();
dummy.setVisible(true);
} public void actionPerformed(ActionEvent e) {
if (e.getSource() == t) {
System.out.println
("\007Being ticked " + Calendar.getInstance().getTime());
}
}
}