Source Code : A texture is a bitmap image applied to a shape

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

A texture is a bitmap image applied to a shape

  

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.TexturePaint;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Textures extends JPanel {
  BufferedImage s;
  public Textures() {
    try {
      s = ImageIO.read(this.getClass().getResource("s.png"));
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    TexturePaint slatetp = new TexturePaint(s, new Rectangle(0, 0, 90, 60));

    g2d.setPaint(slatetp);
    g2d.fillRect(10, 15, 90, 60);

  }

  public static void main(String[] args) {
    JFrame frame = new JFrame("Textures");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new Textures());
    frame.setSize(360, 120);
    frame.setVisible(true);
  }
}

   
    
  

Thank with us