Vertical Gradient Paint : Gradient Paint « 2D Graphics « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » 2D Graphics » Gradient Paint 
16.18.4.Vertical Gradient PaintPrevious/Next
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class GradientsVertical extends JPanel {

  public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2Dg;

    GradientPaint gp1 = new GradientPaint(2525, Color.blue, 1525, Color.black, true);

    g2d.setPaint(gp1);
    g2d.fillRect(2020030040);

  }

  public static void main(String[] args) {

    JFrame frame = new JFrame("GradientsVertical");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new GradientsVertical());
    frame.setSize(350350);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
}
16.18.Gradient Paint
16.18.1.Gradients: a smooth blending of shades from light to dark or from one color to another
16.18.2.Control the direction of Gradients
16.18.3.Horizontal Gradients
16.18.4.Vertical Gradient Paint
16.18.5.Gradients in the middle
16.18.6.Cyclic Gradient PaintCyclic Gradient Paint
16.18.7.Acyclic Gradient PaintAcyclic Gradient Paint
16.18.8.String gradient paintString gradient paint
16.18.9.A non-cyclic gradient
16.18.10.Drawing with a Gradient Color
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.