Microsoft SDK for Java

Graphical Services

The display of graphical objects in Microsoft® Windows® occurs through the graphics device interface (GDI), a device-independent graphics output model that processes graphical function calls from a Windows-based application and passes those calls to the appropriate device driver. The driver performs the hardware-specific functions that generate output. By acting as a buffer between applications and output devices, the GDI presents a device-independent view for the application while interacting in a device-dependent format with the device.

Application developers use the functionality of the GDI to display images, to draw controls, shapes, and text, and to create and use pens, brushes, and fonts. The Windows Foundation Classes for Java (WFC) Graphics object coordinates with other WFC objects, such as the Pen, Font, and Brush objects, to encapsulate these capabilities as Java-based objects.

In the WFC environment, graphical output occurs through the Graphics object. After creating or retrieving a Graphics object, you associate other graphics-based objects, such as fonts, pens, and brushes with the object, and then use the object's numerous drawing methods to render output to the display. For example, to draw lines with a specific appearance, you use the Graphics object's setPen method to specify the pen that the object will use for drawing, and then use the object’s drawLine method to render the lines. You can modify these associations as often as you want.

This topic contains the following sections:

Creating a Graphics Object

Retrieving a Graphics Object

Graphics Object Scope

Maintaining the Bounding Rectangle

Performing Handle-Based Operations

The Graphics Object Coordinate System

Drawing Text

Using the Font Object

Using Pens

Using Brushes

Drawing Bitmaps

Raster Operations

Drawing Shapes

© 1999 Microsoft Corporation. All rights reserved. Terms of use.