Chapter 7. Graphics

 

The main reason for the popularity of the SWT/JFace toolset is its use of the operating system’s native widgets. Most users, accustomed to their operating system, prefer applications that resemble their environment. They want widgets that look and operate similarly from one GUI to the next. But sometimes, a developer needs to go beyond built-in parts and create components of his own. Customized controls add a sense of individuality to a user interface, and images may be necessary for visually oriented applications. In these situations, it’s necessary to understand the graphics capabilities of the SWT/JFace toolset.

This chapter’s goal is to provide that understanding. To meet this goal, we’ll proceed from general concepts to specific applications. The first section will describe the class that makes the toolset’s graphical capability possible: the graphic context. Then, we’ll explain how SWT works with colors and how JFace makes this easier. The third section will show how SWT and JFace allow applications to use text with different fonts and graphical properties. Finally, we’ll show how the SWT and JFace libraries create and modify images, and when to use the methods of one library over the other.

7.1. The graphic context

7.2. Programming with colors

7.3. Displaying text with fonts

7.4. Incorporating images in graphics

7.5. Updating the WidgetWindow

7.6. Summary