Chapter 6. Performing Custom Painting

 <  Day Day Up  >  

http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html

You might not need to read this chapter at all. Many programs get by with no custom painting. 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. To change the look of all components, they use a customizable look and feel, such as the GTK+ look and feel.

If you can't find a way to make a component look the way you want it to, then read on. This chapter introduces painting concepts, as they apply to Swing components, and then refers you elsewhere so you can write painting code that makes your custom components look great.

This chapter contains the following sections:

  • How Swing Components Are Displayed describes how painting happens, with special attention to the framework provided by JComponent .

  • Introduction to Painting Concepts gives an overview of the coordinate system, including how borders affect it, and discusses the Graphics and Graphics2D classes.

  • Implementing a Custom Component tells how to implement painting code within a Swing component using the paintComponent method.

  • At the end of this chapter, the Summary summarizes this chapter and points to where you can find out more. Questions and Exercises tests what you've learned in this chapter. Finally, Example Programs lists all the examples in this chapter and indicates where you can find them on the CD and online.

If you run into any problems, you should consult the section Solving Common Painting Problems (page 740) in the Appendix.

How Swing Components Are Displayed

How Painting Happens

The Swing Painting Methods

An Example of Painting

Repainting Transparent Components

Introduction to Painting Concepts

The Coordinate System

The Graphics Object and Graphics2D

Implementing a Custom Component

An Example of Custom Painting

Summary

Questions and Exercises

Example Programs

 <  Day Day Up  >  


JFC Swing Tutorial, The. A Guide to Constructing GUIs
The JFC Swing Tutorial: A Guide to Constructing GUIs (2nd Edition)
ISBN: 0201914670
EAN: 2147483647
Year: 2004
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net