O'Reilly logo

Java™ After Hours: 10 Projects You'll Never Do at Work by Steven Holzner

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

Drawing Some Graphics

The central method in Painter is the paint method. This is where all the drawing operations take place—drawing lines, ellipses, rectangles, text, with a wide variety of effects. To make those effects happen, Painter uses Java 2D—that is, Graphics2D objects, not the Graphics objects used in the previous chapters.

To let the user expand and reduce figures interactively while dragging the mouse, Painter uses two different Graphics2D objects—one corresponding to the internal image where the final figure is stored when the user is done drawing, and one corresponding to the window while the user is dragging the mouse. To make the drawing operations easier, the current graphics context is stored in a variable named gImage, and ...

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