文档

Java™ 教程-Java Tutorials 中文版
解决常见的绘画问题
Trail: Creating a GUI With JFC/Swing
Lesson: Performing Custom Painting

解决常见的绘画问题

Problem:I don't know where to put my painting code.

Problem:The stuff I paint doesn't show up.

Problem:My component's foreground shows up, but its background is invisible. The result is that one or more components directly behind my component are unexpectedly visible.

Problem:I used setBackground to set my component's background color, but it seemed to have no effect.

Problem:I'm using the exact same code as a tutorial example, but it doesn't work. 为什么?

Problem:How do I paint thick lines?patterns?

Problem:The edges of a particular component look odd.

Problem:Visual artifacts appear in my GUI.

Problem:The performance of my custom painting code is poor.

Problem:The same transforms applied to seemingly identical Graphics objects sometimes have slightly different effects.

If you don't see your problem in this list, see Solving Common Component Problems and Solving Common Layout Problems.


Previous page: Summary
Next page: Questions and Exercises: Performing Custom Painting