Rob Spoor, thanks for your help . I inserted super.paint(g) as first statement in for loop, it is making the old image disapear but only afetr for loop executes four times , i want to see only one image at one time , further help would be appreciated and thanks for suggesting javax.swing.Timer, i would try it.
ok, i made few changes in the logic to erase the previous image plus some additional functionality to revert the ball back to its original position and it worked thanks for helping guys.
Dear Rob Spoor will you please help me how can i do this by using javax.swing.Timer instead of sleep() methd. thanks
Hear is the code:
Step 2: get rid of the Thread variable completely.
Step 3: create a javax.swing.Timer object. Create a new ActionListener (an anonymous inner class will be good); this ActionListener will call the repaint method in its actionPerformed method.
Step 4: tweak the timer's settings as necessary.
Step 5: start the timer.
Step 6: enjoy your program.