Studyon Minte9.com
Java SE




Gradient




package testexample; import java.awt.*; import java.awt.geom.Line2D; import javax.swing.*; public class Test extends JFrame { public static void main(String[] args) { Test frame = new Test(); frame.setBounds(200, 200, 400, 300); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setVisible(true); } public Test() { add( new JPanel() { @Override public void paintComponent(Graphics g1) { super.paintComponent(g1); Graphics2D g = (Graphics2D) g1; g.setPaint(new GradientPaint(50, 50, Color.green, 50, 150, Color.red)); // --- Look Here --- // g.setStroke(new BasicStroke(3)); int start = 50; int height = 150; int x1 = 50; int x2 = 50; int y1 = 50; int y2 = 150; for (int i=0; i<200; i += 10) { x1 = start + i; x2 = x1; y1 = (i < 100) ? start + i : y1 - 10; y2 = y2; g.draw(new Line2D.Double(x1, y1, x2, y2)); } } }); } }