Not sure why you need an alternative to drawing two rectangles, if that's the result you wish to achieve. This being said, have a look at the GradientPaint class
GradientPaint (Java Platform SE 7 )...