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:

A mouse pressed event occurs in a Component equipped with a Rubberband.
The mouse is dragged inside of the Component where the mouse pressed event occurred.
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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.