[ad_1]
Check out Custom Painting Approaches
It shows the two common ways to do this:
Keep an ArrayList of Objects to paint and then iterate through the List in the paintComponent() method.
Paint directly to a BufferedImage and then just display the BufferedImage.
[ad_2]
solved Drawing an unknown number of shapes [closed]