Java examples for 2D Graphics:Color
paint Gradient
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { static void paintGradient(JComponent c, Graphics g, Paint... paints) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (Paint paint : paints) { g2d.setPaint(paint);/* w ww . java 2 s . co m*/ g2d.fillRect(0, 0, c.getWidth(), c.getHeight()); } } }