Ovals, Gradient Fills and Paint Objects
The first shape we draw is an oval filled with gradually changing colors. Lines 28–29 invoke Graphics2D
method setPaint to set the Paint object that determines the color for the shape to display. A Paint
object implements interface java.awt.Paint
. It can be something as simple as one of the predeclared Color
objects introduced in Section 13.3 (class Color
implements Paint
), or it can be an instance of the Java 2D API’s GradientPaint
, SystemColor, TexturePaint
, LinearGradientPaint
or RadialGradientPaint
classes. In this case, we use a GradientPaint
object.
Class GradientPaint
helps draw a shape in gradually changing colors—called a gradient. The GradientPaint
constructor used here requires seven arguments. ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.