This or something like it may or may or not be ... useful-to-you/ what-you're-looking-for ? You say 'moving the mouse', that's a bit vague ...
import java.util.Random;
import javax.swing.*;
import java.awt.event.*;
public class junk extends JFrame implements ActionListener {
JButton a,b;
JLabel l;
java.text.DecimalFormat d = new java.text.DecimalFormat("#0.##");
double r,s;
String result ="";
public junk(){
super("Timer Buttons");
JPanel p = new JPanel();
p.setSize(200,200);
p.setOpaque(false);
p.setLayout(new java.awt.FlowLayout() );
a = new JButton("first");
a.addActionListener(this);
p.add(a);
b = new JButton("last");
b.addActionListener(this);
p.add(b);
l = new JLabel(result);
p.add(l);
getContentPane().add(p);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==a) r = System.currentTimeMillis();
if(e.getSource()==b) {
s = System.currentTimeMillis();
s -=r;
s /=1000;
l.setText("That took "+d.format(s)+" seconds");
}
}
public static void main(String[] args) {
junk frame = new junk();
frame.setSize(200,200);
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.setVisible(true);
}
}
> I mean when I click on a position with my mouse, the
> animation will start (using timer object)
You will need a MouseListener for that (or MouseAdapter if you are lazy, but adapters are evil !) and override the mouseClicked method. This mouseClicked method should then start your Timer. Question remains: does the animation needs to be canceled and restarted every time you click ? If yes, then stop the timer and start of a new one. If no, just ignore the clicks until the animation is finished.
It would be a lot easier for me to answer if you gave more information ...
jpwinne