GradientFillpublic class GradientFill extends Component Fill a Polygon with a colored gradient |
Fields Summary |
---|
Polygon | pThe points we draw | GradientPaint | gpThe gradient we paint with |
Constructors Summary |
---|
public GradientFill()Construct the drawing object
p = new Polygon();
// make a triangle.
p.addPoint(0,100);
p.addPoint(200,0);
p.addPoint(200,200);
|
Methods Summary |
---|
public java.awt.Dimension | getPreferredSize()
return new Dimension(210, 210);
| public void | paint(java.awt.Graphics g)
Graphics2D g2 = (Graphics2D)g;
g2.draw(p);
gp = new GradientPaint(50.0f, 50.0f, Color.red,
75.0f, 75.0f, Color.green, true);
g2.setPaint(gp);
g2.fill(p);
|
|