The Rubberband Base Class

Before looking at the code for the Rubberband base class, let's briefly outline the steps involved in rubberbanding a shape on screen:

1.
A mouse pressed event occurs in a Component equipped with a Rubberband.
2.
The mouse is dragged inside of the Component where the mouse pressed event occurred.
3.
A mouse released event occurs in the same Component.

Step one defines the anchor point for the rubberband. The anchor point remains constant throughout the remaining steps.

Step two involves dynamically updating the stretch point for the rubberband; the stretch point is kept in synch with the last mouse drag location.

Step three defines the end point for the rubberband. After a rubberbanding operation is complete, a rubberband ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.