serabile serabile - 10 months ago 41
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() {

public void actionPerformed(ActionEvent ae) {


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


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 or java.util.Timer