Graphics
is a shared resources, that is, every component that is painted during a paint cycle uses the same Graphics
context.
One of the jobs of paintComponent
is to prepare the Graphics
context for painting by the component, failing to call super.paintComponent
EVERY TIME paintComponent
is called is leaving what ever was previously painted to the Graphics
context in tact.
Call super.paintComponent
every time paintComponent
is called.
Painting in Swing is destructive, that is, you are expected to repaint the entire state of your component whenever paintComponent
is called.