Java sampling pixel color in swing
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.

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.

1.  Does anyone know how to sample the color of a pixel when all I have access to is the Graphics object?

2.  Is there a better way to draw a custom image as the textfield background other than overriding paintBackground in TextfieldUI?

Thanks
Java sampling pixel color in swing
===

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.

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.

1.  Does anyone know how to sample the color of a pixel when all I have access to is the Graphics object?

2.  Is there a better way to draw a custom image as the textfield background other than overriding paintBackground in TextfieldUI?

Thanks