I have a question about repainting a graphic object in Java.
I have a JPanel on which I draw polygons or rectangles. When I double-click in a polygon, the polygon is identified and it is rendered by a certain color. However the way I’m doing this seems very ineffective because I repaint the entire panel while only one of them needs to be repainted. Now my question is:
Can we define and call a paint method for a Rectangle or GeneralPath (used as polygon)? If yes, would you please recommend a link to explain that?
See
repaint(Rectangle).