title: How to have a Label inherite a Composite's GC in SWT
body: <p>I'm writing an app and our designers want to use gradients for some of the backgrounds on a few of our composites. </p>
  
  <p>I wrote the following code:</p>
  
  <pre><code>composite.addListener (SWT.Paint, new Listener () {
      public void handleEvent (Event e) {
              GC gc = e.gc;
              Rectangle rect = composite.getClientArea ();
              Color color1 = new Color (display, 0, 0, 0);
              Color color2 = new Color (display, 255, 255, 255);
              gc.setForeground(color1);
              gc.setBackground(color2);
              gc.fillGradientRectangle (rect.x, rect.y, rect.width, rect.height , true);
  
          }
      });
  </code></pre>
  
  <p>This draws the gradient fine on the composite, but we have Label/CLabels, Canvases and Links on top of the composite. </p>
  
  <p>In these areas, the background is just the plain gray you get when drawing an empty canvas. </p>
  
  <p>I've tried forcing the Labels to inherit the background like so:</p>
  
  <pre><code>label.setBackgroundMode(SWT.INHERIT_DEFAULT) //SWT.INHERIT_FORCE Doesn't work either
  </code></pre>
  
  <p>But this leaves me with the same default gray and no gradient behind the components on top of the Composite. </p>
  
  <p>Any suggestions for getting the gradient to be the background of each element?</p>
  
  <p>I wouldn't be opposed to drawing the Gradient onto a gc with an image supplied and then setting the background to that Image. However that method just hasn't been working at all, composite or any of its elements. </p>
  
  <p>Also it's not possible for me to set the gradient individually to my knowledge. We want the whole composite to be one uniform flowing gradient. </p>
  
  <p>[edit] I uploaded an example upto twitpic <a href="http://twitpic.com/d5qz" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Thanks,</p>
  
  <p>Brian Gianforcaro</p>