Graphics Parameters

The Graphics class fulfills two major responsibilities:

  • Set and get graphical parameters

  • Perform graphical operations in an output device

The main focus of attention for the Graphics class is the second item, to which most of this chapter is devoted. This section takes a brief look at the graphical parameters that are maintained by the Graphics class:

  • Color

  • Font and font metrics

  • Clipping rectangle

  • Graphics mode

The Graphics class provides get and set methods for color, font, and clipping rectangle. Graphics mode is a write-only property, while font metrics is a read-only property.[1]

[1] Font metrics are associated with a specific font, so font metrics can be changed by changing the Graphics' font.

Each Graphics maintains a single ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.