serabile serabile - 5 months ago 12
Java Question

how to use timer with SwingWorker

need an example, how to use timer in SwingWorker ? because it impossible to add an ActionListener to my Timer like that !

private Timer timer = new Timer(100, new ActionListener() {

@Override
public void actionPerformed(ActionEvent ae) {

}
});


Message Error : The constructor Timer(int, new ActionListener(){}) is undefined

Answer

There is nothing wrong in your source, looks like you are importing different Timer class. Are your using javax.swing.Timer. Refer the API document here.

May be you had imported javax.management.timer.Timer or java.util.Timer

Comments