Previous | Next | Trail Map | 2D Graphics | Contents

2D Graphics

by Deborah Adair


This is a draft! Please send comments and suggestions on this trail to tutorial@java.sun.com with the word "2D" in the subject.
This trail introduces you to the Java 2D API and shows you how to display and print 2D graphics in your Java programs. With the Java 2D API, you can easily:

For example, using the Java 2D API, you could display complex charts and graphs that use different line and fill styles to distinguish sets of data:

The Java 2D API also enables you to store and manipulate image data--for example, you can easily perform image-filter operations such as blur and sharpen.

This trail covers the most common uses of the Java 2D APIs and briefly describes some of the more advanced features. For additional information about using the Java 2D APIs, see the Java 2D Programmer's Guide. The JavaTM Developer ConnectionSM has more information in Java 2D: A Tutorial on Styled Text. Additional sample programs illustrating the Java 2D API features are also available online.

The Java 2D APIs are closely integrated with the Abstract Windowing Toolkit (AWT). If you are not familiar with AWT, you might find it useful to review the AWT documentation, Creating a User Interface(in the Creating a User Interface trail) before reading this trail.

Overview of the Java 2D API introduces the key Java 2D concepts and describes the Java 2D rendering model.

Displaying Graphics with Graphics2D teaches you how to set up the Graphics2D rendering context to use fancy stroke and fill styles, perform transformations, clip the drawing region, composite overlapping graphics, and specify rendering preferences.

Manipulating and Displaying Images describes how to implement double-buffering and perform image-filter operations with BufferedImage objects.

Printing teaches you how to render 2D graphics to a printer and print complex documents.


Previous | Next | Trail Map | 2D Graphics | Contents