My issue here with ball animation is that the ball is moving in a straight line leaving behind a trail. My expected output is that there should be no trail of the ball.
The code determines the movement of the ball in just one direction along X axis.
public class App extends JFrame implements Runnable{
int x=0,y=250;
public void run() {
for(;;) {
try {
repaint();
x++;
Thread.sleep(10);
} catch(Exception e){}
}
}
public void paint(Graphics g) {
g.drawOval(x,y,30,30);
}
public static void main(String[] args) {
App frame= new App();
frame.setTitle("Bounce");
frame.setSize(400, 450);
frame.setVisible(true);
Thread t1 = new Thread(frame);
t1.start();
}
}