Here you can find the source of gradientPaint(Graphics2D g2d, Point2D startPosition, Color startColor, Point2D endPosition, Color endColor, int sx, int sy, int ex, int ey)
public static void gradientPaint(Graphics2D g2d, Point2D startPosition, Color startColor, Point2D endPosition, Color endColor, int sx, int sy, int ex, int ey)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.geom.Point2D; public class Main { public static void gradientPaint(Graphics2D g2d, Point2D startPosition, Color startColor, Point2D endPosition, Color endColor, int sx, int sy, int ex, int ey) { GradientPaint gradient = new GradientPaint(startPosition, startColor, endPosition, endColor, true); g2d.setPaint(gradient);// w w w . j a v a 2s . c o m g2d.fillRect(sx, sy, ex, ey); } }