I looked for this and could not find it anywhere. I have a RoundedRectangle2D Component that represents my health bar in a game, and when I call a subtractHealth method, I want it to proportionally paint a section of the rectangle red over the green, making it look like the health bar lost health. I previously had two rectangles, a green one and a red one, one behind the other, but I was told I should change this, and I agreed it would be one less bit of memory used, so does anyone know how to do this?
You could use the GradientPaint class. http://www.roseindia.net/java/example/java/swing/graphics2D/gradient-paint.shtml