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

Printing

You can print a Graphics object—but not just any Graphics object; you can only print a PrintGraphics object. You can either manually draw into the graphics or have a component draw into it; either way, after you are done painting into the graphics, you can turn around and print it. If a component prints into the graphics object and the component is a container, you can choose to print all of the components contained within the container's containment hierarchy.

Obtaining a Reference to a PrintGraphics

Whether you want to paint a (hierarchy of) component(s) or you just want to paint into a graphics object and then print it, you must first obtain a reference to a special extension of the Graphics class—a PrintGraphics. This is a four-step ...

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