You don't want a while() loop in the mouseListener. You want to increment a counter each time a point is collected until you have recorded the required number of points for your polygon. You may only want to draw the points themselves until you have the entire polygon specified. You'll also need some way to reset it. Perhaps a seventh click or a right-click should clear the points and reset the counter.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847