FileDocCategorySizeDatePackage
TexturePaintFill.javaAPI DocExample1341Mon Apr 05 10:10:16 BST 1999None

TexturePaintFill

public class TexturePaintFill extends ApplicationFrame

Fields Summary
private BufferedImage
mImage
Constructors Summary
public TexturePaintFill(String filename)

    // Load the specified JPEG file.
    InputStream in = getClass().getResourceAsStream(filename);
    JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
    mImage = decoder.decodeAsBufferedImage();
    in.close();
  
Methods Summary
public static voidmain(java.lang.String[] args)

    TexturePaintFill f = new TexturePaintFill("roa2.jpg");
    f.setTitle("TexturePaintFill v1.0");
    f.setSize(200, 200);
    f.center();
    f.setVisible(true);
  
public voidpaint(java.awt.Graphics g)

    Graphics2D g2 = (Graphics2D)g;
    // Create a round rectangle.
    RoundRectangle2D r = new RoundRectangle2D.Float(25, 35, 150, 150, 25, 25);
    // Create a texture rectangle the same size as the texture image.
    Rectangle2D tr = new Rectangle2D.Double(0, 0,
        mImage.getWidth(), mImage.getHeight());
    // Create the TexturePaint.
    TexturePaint tp = new TexturePaint(mImage, tr);
    // Now fill the round rectangle.
    g2.setPaint(tp);
    g2.fill(r);