I am trying to make a simple ball animation, that starts from 1 corner and goes to another corner of the panel. I have written a program for that.
When I run the program the oval
or ball leaves the trail. What I mean to say is that it leaves it's 'color trail' when the program runs. In my program timer
fires an event every 100 milliseconds.
The following is the logic responsible for running the code :
void function() {
// in this there is a action listener timed accordingly to fire event of
// doing x++ every 100th miliseconds
}
public void paintComponent(final Graphics g) {
g.setColor(Color.black);
g.drawOval(x,y,width,height);
g.fillOval(x,y,width,height);
}
Screen shot of the output :