wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes Draw multiple circles on mouse click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Draw multiple circles on mouse click" Watch "Draw multiple circles on mouse click" New topic

Draw multiple circles on mouse click

George Holloway

Joined: Jan 28, 2012
Posts: 3

Hi all,

So far i managed to get a circle to show itself on the JPanel when the mouse is clicked. The only problem i have is that it doesn't show multiple circles when clicked, instead it deletes the pervious one. I have a method called paint() where the graphics is drawn.

From what i read is that i need to make a array list of Shape at the beggining of my class and add a for loop in the paint() method.

For loop at the bottom of paint() method.

But this doesn't work as it displays text only since it is in front of the loop. Could you please show me some tutorial or another post here so i can solve this? Also some people override the paintGraphics() method, is this necessary? Or i can create my own method? Should i also store the cooridnates from mouseX and mouseY somewhere as well?
Darryl Burke

Joined: May 03, 2008
Posts: 5115

The correct method to override is paintComponent(....). I've never come across any paintGraphics method, where did you find tthat?

Did you add any Shapes to the ArrayList?

Learning resources:

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link: http://aspose.com/file-tools
subject: Draw multiple circles on mouse click
jQuery in Action, 3rd edition