浏览 1380 次
锁定老帖子 主题:Swing Timer
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2010-11-10
Timer timer = new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("repaint " + Thread.currentThread().getName()); Random rand = new Random(); int base = rand.nextInt(100); textField_1.setText("" + base); textField_2.setText("" + (base+1)); textField_3.setText("" + (base+2)); textField_4.setText("" + (base+3)); }}); timer.start(); something like this works. Intrinsically, there is a thread dedicated for running this actionPerformed() every second. This thread actually fired actionEvents to our listener. 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |