How to implement oval GradientPaint?
问题 We know that there are a class named RadialGradientPaint in Java and we can use it to have a gradient painting for circle. But I want to have an oval (ellipse) GradientPaint . How to implement oval GradientPaint ? 回答1: Use an AffineTransform when drawing the RadialGradientPaint . This would require a scale instance of the transform. It might end up looking something like this: import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import java.awt.geom.*; import java.awt.event.*