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 O’Reilly online learning.

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