Switch to full style
General Java code examples
Post a reply

Textured Paint

Tue Nov 11, 2008 8:32 pm

draw Textured Paint in java
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;

public class 
ShowTexturePaint extends JPanel {
 
  public 
void paint(Graphics g) {
    
Graphics2D g2d = (Graphics2Dg;
    
BufferedImage bufferedImage = new BufferedImage(88,
        
BufferedImage.TYPE_INT_RGB);
    
Graphics2D g2 bufferedImage.createGraphics();
    
g2.setColor(Color.red);
    
g2.fillRect(0088);
    
g2.setColor(Color.gray);
    
g2.fillOval(0088);
    
Rectangle2D rect = new Rectangle2D.Double(5588);
    
g2d.setPaint(new TexturePaint(bufferedImagerect));
    
Ellipse2D oval = new  Ellipse2D.Double(8,8,250,250);
    
g2d.fill(oval);
  }
  public static 
void main(String args[]) {
    
JFrame frame = new JFrame("Show Texture Paint");
    
ShowTexturePaint texturePaint = new ShowTexturePaint();
    
frame.getContentPane().add("Center"texturePaint);
    
frame.setSize(350300);
    
frame.setVisible(true);
  }



Attachments
texturePaint.gif
Java textured paint
texturePaint.gif (7.63 KiB) Viewed 5211 times

Post a reply

Topic Tags

Java Graphics