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();
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
Can someone help me pls? I've installed the last Java version^^
Thx a lot.
your import is wrong there correct that
change
to
take a look at your imports. Eclipse has auto imported
java.util.Timer
. Change that tojavax.swing.Timer
and you should be on your way.Import
javax.swing.Timer
notjava.util.Timer
.Swing
Timer
has a constructor Timer(int , java.awt.event.ActionListener).