Q: Timer doesn't feel like overriding A friend of mine gave me this code for a timer. I must say that I'm a beginner, so I don't understand what @Override is, but the code worked for other friends.


*

*tijd is an int with the value of 10

*lx is the x value of a label 

*s1 is also an int with a value of 3


Eclipse says about the public void line:

Multiple markers at this line:
  
  
*
  
*The method actionPerformed(ActionEvent) of type new ActionListener(){} must override a superclass method
  
*implements java.awt.event.ActionListener.actionPerformed
  

The code is:
 final Timer t = new Timer(tijd, new ActionListener(){
    @Override
    public void actionPerformed(ActionEvent e) {
        lx = lx-s1;
    }
});
t.start();

With it comes the suggestion of deleting @Override, but as I'm not sure of what it does I don't know if I'll be deleting an important thing of the code. I suppose it isn't there because some-one thought it would be funny to include the code.
So my questions are:
1. How do I move the label?
2. What is the problem with @Override?

A: What you're doing here is creating on the spot an anonymous implementation of the ActionListener interface and passing this directly as the second argument of the Timer constructor Timer(int x, ActionListener y).
Any implementation of this interface must provide an implementation of the method ActionPerformed (ActionEvent e), so you provide this in place. Implementations of an interface method have to be annotated with the @Override tag as of Java 6. If you're using Java 5 it's optional.
You could have written your code like this, using a named (non-anonymous) class:
static class LabelMover implements ActionListener {
  @Override
  public void actionPerformed(ActionEvent e) {
  ...
  }
}

Timer timer = new Timer (tijd, new LabelMover());

This would lead to the same behavior.
The question is however: which Timer class are you using here? The Java Timer class (java.util.Timer) does not have a constructor that takes an ActionListener as a second parameter.
If you want to have the label moved incrementally every so many milliseconds then you should create a TimerTask that does that and then create a Timer and schedule the TimerTask with that timer:
static class LabelMover implements TimerTask {
    @Override
    public void run() {
    // code to move the label
    }
}
Timer timer = new Timer();
timer.schedule(new TimerTask(), 0, tijd);


A: Well, indeed the @Override is negligible in this case. Yet, the codes for moving the label is of great importance. 
You should base it on this:
In the action listener of the timer do something like this: x = x - 1;
And then Label.setLocation(x,y);
That should do the trick!
