I have created a program that draws a thick line.
import javax.swing.*;
import java.awt.*;
public class Movement {
    int xGrid = 50;
    public static void main(String[] args) {
        Movement m = new Movement();
        m.animate();
    }
    public void animate() {
        JFrame frame = new JFrame("Movement");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ScreenDisplay display = new ScreenDisplay();
        frame.getContentPane().add(display);
        frame.setSize(400, 400);
        frame.setVisible(true);
        for (int aL = 0; aL < 200; aL++) {
            xGrid++;
            display.repaint();
            try {
                Thread.sleep(50);
            } catch (Exception ex) { }
        }
    }
    class ScreenDisplay extends JPanel {
        public void paintComponent(Graphics g) {
            g.setColor(Color.RED);
            g.fillOval(xGrid, 175, 50, 50);
        }
    }
}
Because of the method "Thread.sleep(50)", the speed of the program slows down a little.
So I got a little curious and removed the "sleep()" method.
What I expected to output was the exact same output, just extremely fast.
However, it just prints out one circle in the frame.
I don't really know why it outputs just one circle, none of the researches I've done back up the answer.
Can anyone please explain why?
 
    