Java Code
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class Graphics2DStroke 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+20, y, w, h);
GradientPaint gp = new GradientPaint(50, 75, Color.yellow, 95, 95, Color.blue, true);
g2.setPaint ( gp ); // fill with gradient
// Stroke
g2.setStroke( new BasicStroke( 8 ) ); // outline is 8 pixels
g2.draw( ellipse );
// Stroke with a gradient.
g2.setStroke( new BasicStroke( 20 ) ); // outline is 20 pixels
g2.draw( ellipse2 );
}
}
©2007-2008 by E.S.Boese. All Rights Reserved