Start of Tutorial > Start of Trail |
Search
Examples Index |
You might not need to read this lesson at all. Many programs get by with no custom graphics. If they display images, they do so using icons in standard Swing components such as labels and buttons. To display styled text, perhaps with embedded images and components, they use text components. To customize the edges of components, they use borders.If you can't find a component that paints what you need onscreen, then read on. This lesson teaches you how to display text, simple shapes, and images, using API that works in both JDK 1.1 and 1.2. Our examples create custom components, but you might also use this API when creating a custom border or icon implementation. This lesson finishes with information about animation.
Note: If you're using only Java 2 (JDK 1.2, and not JDK 1.1) then in addition to reading the relevant pages in this lesson, you should read the 2D Graphics trail. That trail describes the JavaTM 2D Graphics API, which provides much more functionality than the graphics primitives described in this lesson.
This section gives you the information you need to start implementing custom painting in components.
This section teaches you how to paint simple shapes and display text effectively. It includes examples of using theGraphics
,Font
, andFontMetrics
classes.
This section discusses how the Java platform supports images and tells you how to load and display images.
Many programs perform animation,
whether it's the classic, cartoon-style animation of Duke waving
or simply moving static images across the screen.
This section tells you how to perform animation,
using a Timer
object
to implement an animation loop.
This section describes some common problems of graphics programs, along with possible solutions to these problems.
Start of Tutorial > Start of Trail |
Search
Examples Index |