CSC 112
Ileana Streinu
22. Polygon closed with Button.
1. Start over
Modify the applet by adding an extra button New (or Clear) to start over. When the user clicks on the "New" button, the polygon
becomes "empty", and any subsequent clicks on the applet add new vertices and edges to it.
2. Smoother drawing
The click-only design feels clumsy. A better design is as follows:
- A new point is recorded when the mouse is pressed, or updated when it is being dragged.
- A polygonal line is drawn at each mouse event (including during dragging motion).
3. Filled polygon
Add a new button to draw a filled polygon.
4. Label the points
When the polygon is displayed, its vertices appear numbered. Hint: use the drawText method
to paint the label on the applet.