List of usage examples for java.awt GradientPaint createContext
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
AffineTransform xform, RenderingHints hints)
From source file:Main.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gp1 = new GradientPaint(5, 5, Color.red, 20, 20, Color.yellow, true); gp1.createContext(ColorModel.getRGBdefault(), new Rectangle(0, 0, 30, 40), new Rectangle(0, 0, 30, 40), new AffineTransform(), null); System.out.println(gp1.getTransparency()); g2d.setPaint(gp1);//from w w w . j av a2 s . c o m g2d.fillRect(20, 20, 300, 40); }