GradientPaint: iron : Gradient Paint « 2D Graphics GUI « Java






GradientPaint: iron

GradientPaint: iron
    

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

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

public class SimplestGradientPaint extends JPanel{
  public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new SimplestGradientPaint());
    f.setSize(350, 250);
    f.show();

  }

  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Ellipse2D e = new Ellipse2D.Float(40, 40, 120, 120);
    GradientPaint gp = new GradientPaint(75, 75, Color.white, 95, 95,
        Color.gray, true);
    g2.setPaint(gp);
    g2.fill(e);
  }
}

           
         
    
    
    
  








Related examples in the same category

1.Gradients: a smooth blending of shades from light to dark or from one color to another
2.Gradient Shapes
3.GradientPaint demoGradientPaint demo
4.GradientPaint EllipseGradientPaint Ellipse
5.Another GradientPaint DemoAnother GradientPaint Demo
6.Text effect: rotation and transparentText effect: rotation and transparent
7.Text effect: image texture
8.Texture paint Texture paint
9.Round GradientPaint Fill demoRound GradientPaint Fill demo
10.Color gradientColor gradient
11.Drawing with a Gradient Color
12.A non-cyclic gradient
13.A cyclic gradient
14.PaintsPaints
15.Horizontal Gradients
16.Vertical Gradient Paint
17.Gradients in the middle
18.Control the direction of Gradients
19.Returns true if the two Paint objects are equal OR both null.
20.Gradient effects