You can use ImageOps to do the job. Take a look at this tutorial: http://java.sun.com/docs/books/tutorial/2d/images/filtering.html
In particular, this class may be interesting to you:http://java.sun.com/j2se/1.4/docs/api/java/awt/image/ColorConvertOp.html
There's an example of how to use these in the Java2Demo application shipped with the sdk.
Also, if the color you're replacing is transparent (that is, alpha is x00), you can use Graphics.drawImage(image, w, h, Color) to replace it with provided color when you copy the image to the destination.