serabile
serabile

Reputation: 327

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

Upvotes: 0

Views: 826

Answers (1)

Jayamohan
Jayamohan

Reputation: 12924

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

Upvotes: 5

Related Questions