I need to draw custom shapes. Now when a user clicks on several points on the panel I create a shape using a polygon.
public void mouseClicked(MouseEvent e)
The ImageJ project has a particularly nice implementation of a Polygon tool with adjustable vertices, as seen here and here.