Java - 使用Timer时出错 [英] Java - Error on use of Timer
问题描述
所以我用谷歌搜索了几分钟如何使用计时器,并在这里找到了一些有用的线程。但是当我想使用建议的代码时,Eclipse向我显示总是一个错误。
So I have googled some minutes how to use the timer and found some helpfull threads here. But when I want to use the suggested code Eclipse shows me always an error.
int delay = 1000; //milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
label.setVisible(false);
}
};
new Timer(delay, taskPerformer).start();
这是我现在想要使用的代码。 Eclipse强调最后一行,当他们建议删除匹配'Timer()'的参数时。此外,它强调start()并希望它被转换。 :S
This is my code I want to use now. Eclipse underlines the last line and when they suggest to "remove arguments to match 'Timer()' ". Further it underlines start() and want it to be casted. :S
有人可以帮我吗?我安装了最后一个Java版本^^
Can someone help me pls? I've installed the last Java version^^
很多。
推荐答案
看看你的进口商品。 Eclipse已自动导入 java.util.Timer
。将其更改为 javax.swing.Timer
,您应该在路上。
take a look at your imports. Eclipse has auto imported java.util.Timer
. Change that to javax.swing.Timer
and you should be on your way.
这篇关于Java - 使用Timer时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!