O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required