Java Code

import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class Graphics2DEx extends JApplet
{
	public void paint(Graphics g) 
	{
	    Graphics2D g2 = ( Graphics2D ) g;
	    int x = 15, y = 10, w = 50, h = 50;
	    Ellipse2D ellipse = new Ellipse2D.Double(x, y, w, h);
	    Ellipse2D ellipse2 = new Ellipse2D.Double(x+w, y, w, h );
	    GradientPaint gp = new GradientPaint(50, 75, Color.yellow, 95, 95, Color.blue, true);
	    g2.setPaint(gp);    		// fill with gradient
	    g2.fill(ellipse);
	    g2.fill(ellipse2);
	    g2.fill(new Ellipse2D.Double( x+w+w, y, w, h ) );
	}
}

©2007 by E.S.Boese. All Rights Reserved