我想这很简单,但我真的不能说出错误是什么。
final Timer tiempo= new Timer(1000,new ActionListener()) ;我唯一想要的是,1000的延迟和一个动作监听器,我不完全理解。问题是我总是得到一个错误。“还没有定义。”
使用该方法
final Timer tiempo= new Timer(1000, ActionListener()
{
public void actionPerformed(ActionEvent e)
{
}
}; 仍然没有定义,之前也尝试过创建一个实例
ActionListener actionlistener= new ActionListener();
final Timer tiempo= new Timer(1000, actionlistener()
{
public void actionPerformed(ActionEvent e)
{
}
}; 请解释一下,这是非常令人沮丧的。
Error: ActionListner cannot be resolved to a variable发布于 2013-05-07 12:16:29
final Timer tiempo= new Timer(1000, ActionListener()
{
public void actionPerformed(ActionEvent e)
{
}
}; 应该是new ActionListener()
final Timer tiempo= new Timer(1000, new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
}
}; 你的第二个例子是错误的,原因有很多……
ActionListener actionlistener= new ActionListener(); // This won't compile
// because it is an interface and it requires either a concrete implementation
// or it's method signatures filled out...
// This won't work, because java sees actionlistener() as method, which does not
// exist and the rest of the code does not make sense after it (to the compiler)
final Timer tiempo= new Timer(1000, actionlistener()
{
public void actionPerformed(ActionEvent e)
{
}
}; 它应该看起来更像..。
ActionListener actionlistener= new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
}
};
final Timer tiempo= new Timer(1000, actionlistener);https://stackoverflow.com/questions/16411073
复制相似问题