Drawing with a Gradient Color

public void paint(Graphics g) { Graphics2D g2d = (Graphics2D)g; Color startColor = Color.red; Color endColor = Color.blue; // A non-cyclic gradient GradientPaint gradient = new GradientPaint(startX, startY, startColor, endX, endY, endColor); g2d.setPaint(gradient); // Draw shapes...; see Drawing Simple Shapes // A cyclic gradient gradient = new GradientPaint(startX, startY, startColor, endX, endY, endColor, true); g2d.setPaint(gradient); // Draw shapes...; see Drawing Simple Shapes }

Comments

10 Jan 2010 - 7:58am by phopteque (not verified)

I just want too take some time too thank the active members for doing what you do and making the community what it is im a long time reader and first time poster so i just wanted to say thanks.

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.