Previous | Next | Trail Map | Creating a User Interface | Table of Contents


Working with Graphics

This lesson teaches you everything you need to make your program draw to the screen. You'll learn how to create simple geometric shapes, display text, and display images. Then you'll learn how to animate these shapes and images. This lesson assumes that you've read the Overview of the Java UI(in the Creating a User Interface trail), especially The Anatomy of a GUI-Based Program.

Overview of AWT Graphics Support

This page gives an overview of the AWT support for drawing, with links to where you can find more information.

Using Graphics Primitives

This section teaches you how to draw simple shapes and display text effectively. It includes examples of using the Graphics, Font, and FontMetrics classes. One rectangle-drawing example could be used as the basis for implementing selection in a paint program. [Need to add page on additional drawing techniques: copyArea, clearRect, clipRect (cover clipping under update(), as well).]

Using Images

This section discusses the Java support for images and tells you how to load, display, and manipulate images.

Performing Animation

Many Java programs (especially applets) perform animation, whether it's the classic, cartoon-style animation of Duke waving (visible in the Trail Map(the master page for this tutorial)), program-generated graphics such as a scrolling checkerboard, or simply moving static images across the screen. This section tells you how to perform animation well. It includes tips on improving graphics performance and appearance, using techniques such as implementing the update() method and double buffering. [Need to add clipping to the update() section.]

Common Graphics Problems (and Their Solutions)

Please send suggestions for this section to me.

[Drawing thick lines is one possible topic.]
[Stuff not showing up at all: validate(), check coordinates and size, did you successfully add your component, ....] [You can only reduce, never increase, the display area specified by your Graphics context.] [TextFields that have the focus take 100% of CPU on some systems. One result is that an image won't get drawn until you move the cursor or change the focus to be on another component. Visible in ImageRotator demo.]


Previous | Next | Trail Map | Creating a User Interface | Table of Contents