实现ActionListener接口 int delay = 1000; //milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
//...Perform a task...
this.increasesecond();
}
};
new Timer(delay, taskPerformer).start();
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
//...Perform a task...
this.increasesecond();
}
};
new Timer(delay, taskPerformer).start();
解决方案 »
- 打包成jar文件后运行出现Invalid or corrupt jarfile
- hashcode()问题
- 这几个Java试验怎么做啊
- 在linux radhat下使用 shell脚本 把jar包做成daemon 如何做? 急
- ApplicationFrame这个类是什么类?
- 有人在Eclipse下用过JFreeChart吗?应该如何配置环境?我只想编java application程序。不是JSP。谢谢!
- java反射技术,持久化的应用!!!!
- 谁有《网络机器人Java编程指南》这本书的配套源码?
- 2个ArrayList 变量怎么合并为一个,谢谢。
- 怎样把一个字符的ASCII码转回一个字符?
- 关于在APPLICATION中显示JPEG图象问题??
- jbuilder中怎样给一个jtextarea增加右键菜单?
你能否给我写详细一点,十分感谢。 题目是这样的:
使用javax.swing.Timer类对象timer,设置0。5秒触发一个动作事件,执行date3对象中的
increaseDay()方法。
class wux extends TimerTask{
public void run(){
System.out.println("hello");
}
}new Timer().schedule(new TimerTask(),1,1000);
class yourclass implement ActionListener{Timer time1,time2;
time1=new Timer(1000,this);
time2=new Timer(2000,new Boy());//boy对象作计时器的监视器
...... time1.start();time2.start();
public void actionPerformed(ActionEvent e)
{text1.append("欢迎光临"+"\n") ;
}
}
}
class Boy implements ActionListener
{ public void actionPerformed(ActionEvent e)
{TimeWin.text2 .append("欢迎光临"+"\n") ;
}
}