I have a paint property which is supposed to fill the top of my component and it does. However if I set it up as a gradient it looks proper on the original size of the component but the gradient doesn't stretch along with the component. I hope some screenshots will make it clear.
The property of type "Paint"
Original component size
Stretched component
The code for painting this part of the component looks like this:
g.setPaint(jobColor);
g.fill(binHeader);
g.setPaint(strokePaint);
g.draw(binHeader);
where binHeader
is an Ellipse2D
object
Try using a RelativeLinearGradientPaint
?
Similar to LinearGradientPaint, but this one specifies it's points as percentages of the user-space bounds of the object it will fill.
Having the property setup as type Paint
allows for this window (see screenshot) to popup and set the fill to either solid, linear gradient, or radial gradient. If I change the property type to RelativeLinearGradientPaint
, then I lose that variety.
Actually, apparently that editor spits out a RelativeLinearGradientPaint anyways, so it's not the quick fix to your problem.
Can you try specifying the shape size by calling the beforePaint
method if the paint you have is a RelativePaint
?
Not sure how to go about that
Something like this:
if (fillPaint instanceof RelativePaint) {
((RelativePaint) fillPaint).beforePaint(logicalBounds);
}
g.setPaint(fillPaint);
1 Like
Perfect, that solved it.
Thank You!
1 Like