posted 12 years ago
Add your mouse listener to your JPanel (that does the drawing) in it's constructor. The constructor is the place to build and initialize variables for your class. I am still using j2se 1.4 so am unable to use the generic form of the Storage vector; thus the declaration of shapes. I made up a Circle class that would allow the code to compile. The general idea in drawing, though you are free to do things any way you want, is to add the Circles to the vector in the mouse code and draw them in the rendering component (the JPanel DP below). I changed the names to avoid name–clashing in your VM.