O'Reilly logo

Sams Teach Yourself Java™ 6 in 21 Days by Laura Lemay, Rogers Cadenhead

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

Chapter 13. Using Color, Fonts, and Graphics

Today, you work with Java classes that add graphics to a graphical user interface with Java2D, a set of classes that support high-quality, two-dimensional images, color, and text.

Java2D, which includes classes in the java.awt and javax.swing packages, can be used to draw text and shapes such as circles and polygons; use different fonts, colors, and line widths; and work with colors and patterns.

The Graphics2D Class

Everything in Java2D begins with the Graphics2D class in the java.awt package, which represents a graphics context, an environment in which something can be drawn. A Graphics2D object can represent a component on a graphical user interface, printer, or another display device.

Graphics2D is ...

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