Java examples for 2D Graphics:Line
render JComponent By Line Graphics
/*********************************************** * Copyright to Arrah Technology 2006 * * http://www.arrah.in * * * * Any part of code or file can be changed, * * redistributed, modified with the copyright * * information intact * * * * Author$ : Vivek Singh * * * ***********************************************/ //package com.java2s; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JComponent; public class Main { public static void renderByLineGraphics(JComponent c, Graphics g) { int colorI = 0; for (int i = 0; i < c.getHeight(); i++) { GradientPaint gp = new GradientPaint(0, 0, new Color(200, 200, colorI), c.getWidth(), i, new Color(200, 200, colorI + 1), true);/*from www. ja v a2 s .co m*/ ((Graphics2D) g).setPaint(gp); g.fillRect(0, i, c.getWidth(), i); if (colorI < 254) colorI++; } } }