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, especially The Anatomy of a GUI-Based Program.
Overview of AWT Graphics SupportThis page gives an overview of the AWT support for drawing, with links to where you can find more information.
Using Graphics PrimitivesThis 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.
Using ImagesThis section discusses the Java support for images and tells you how to load, display, and manipulate images.
Performing AnimationMany Java programs (especially applets) perform animation, whether it's the classic, cartoon-style animation of Duke waving (visible in the first page of Getting Started), 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.
Common Graphics Problems (and Their Solutions)This section describes some common problems of graphics programs, along with possible solutions to these problems.