Inserting multiple shapes using mouseListener
I am currently developing a module that allows users to click on a shape (eg. rectangle) option and then draw it on a canvas. The problem is every time i click to draw the second shape, the shape that is already in the canvas disappears and the new one appears. This disables the user from being able to add more than one shape in the canvas. I found out that every time before calling the repaint() method, the position and the size of the existing shapes have to be recorded since method repaint() will redraw the canvas. Is that true and if so any clue how to do it? Thanks.