• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Control Fundamentals > Filling the Background

4.10. Filling the Background

By default, the background color of a control is filled before a paint event is sent. This allows you to concentrate on drawing the contents of the control. Generally, this approach works well unless you need to provide a custom background. For example, if you are implementing a control that draws a list of strings, alternating the background color between each line, then there are effectively two background colors. Sometimes, there is no notion of background color for a control. For example, a control that draws an image will fill the entire client area with the pixels that make up the image. For this control, filling the area to be drawn with the background color first is completely extraneous, because it will immediately be replaced with the image content. In both these cases, drawing the background can cause the control to flicker.

If you specify the SWT.NO_BACKGROUND style when a control is created, it will not fill the background before sending a paint event. Although this style can get rid of flicker, it means that the paint listener must draw every pixel. Failure to do so will leave the pixels that were on the screen before the paint event was issued untouched. The effect is unsettling, to say the least.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint