• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ambiquity while drawing multiple shapes on Jpanel

 
looka dicosta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a duplicate thread posted in other forum but don't get satisfied answer from their. so Hoping to get a better answer from here.Ambiquity while drawing multiple shapes on Jpanel. 0 down vote favorite


Th code below has few problems :

1) The polygon joins last and first point itself, should not do itself but user should draw it.

2) The polygons lines disappeared after clicking on other shapes.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> It is a duplicate thread posted in other forum but don't get satisfied answer from their

sorry, but unless you post the link, any response here may be just a duplicate

you want help, ok, that = posting the link so we can see the responses, so far,
and perhaps come up with a different/better response.
 
looka dicosta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:> It is a duplicate thread posted in other forum but don't get satisfied answer from their

sorry, but unless you post the link, any response here may be just a duplicate

you want help, ok, that = posting the link so we can see the responses, so far,
and perhaps come up with a different/better response.


other forum link
 
looka dicosta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The link to other forum
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now we all know about the cross’post her …
You ought to tell the chap who replied on SO that you have posted here, too.

Why are you using an image? You would not usually use an image to draw on. You draw directly onto the panel. That should allow the shapes to appear over one another in the order they are painted. The suggestion on the other forum of creating Shape objects and keeping them in a List is sound. Far better than trying to do everything in the paintComponent method.
As for closing or not closing polygons, there are ways to do that, but I can’t remember definitely. I think you may need to learn how to use a GeneralPath object. No, not that; it says to use this instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic