title: Java sampling pixel color in swing
body: <p>I have to create a special TextFieldUI that draws an image as the background.  That image contains some alpha components.  However, whenever a character is written in that text field, first it redraws the background and then draws the character.  This is fine when the background contains no alpha components, but after a few characters have been typed, the alpha areas sum up to become black.</p>
  
  <p>The only way I can see around this is in the paintBackground method of TextfieldUI (which I'm overriding), I have to first sample the color of the background at that location, paint the entire graphics component that color, and then paint my background.</p>
  
  <ol>
  <li><p>Does anyone know how to sample the color of a pixel when all I have access to is the Graphics object?</p></li>
  <li><p>Is there a better way to draw a custom image as the textfield background other than overriding paintBackground in TextfieldUI?</p></li>
  </ol>
  
  <p>Thanks</p>