I have a JFrame.

I also have a Box class which extends Component. This box class has a paint method which makes a filled rectangle.

When I add multiple of these Box components to my JFrame, only the most recently added one is displayed when I call repaint on the JFrame.

I took a look at the layout managers, but I am not sure that's what I want. All I want is to be able to make an animation of whole bunch of rectangles wherever I want on the screen.

(I also tried creating a panel, adding the panel to the JFrame, and then adding all the Box components to the panel. This did not work either).

Thanks in advance!

Edit
Report