paint Vertical Gradient - Java 2D Graphics

Java examples for 2D Graphics:Color Dark

Description

paint Vertical Gradient

Demo Code


//package com.java2s;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Image;

public class Main {
    public static void paintVerticalGradient(Image image, int x, int y,
            int w, int h, int height, Color startColor, Color endColor) {
        Graphics2D g2 = (Graphics2D) image.getGraphics();
        g2.setPaint(new GradientPaint(0, y, startColor, 0, height, endColor));
        g2.fillRect(x, y, w, h);/*from   w  w  w  .  j  av a  2 s .c  o m*/
        g2.dispose();
    }
}

Related Tutorials