Here you can find the source of tileStretchPaint(Graphics g, JComponent comp, BufferedImage img, Insets ins)
public static void tileStretchPaint(Graphics g, JComponent comp, BufferedImage img, Insets ins)
//package com.java2s; //License from project: LGPL import java.awt.Graphics; import java.awt.Insets; import java.awt.image.BufferedImage; import javax.swing.JComponent; public class Main { public static void tileStretchPaint(Graphics g, JComponent comp, BufferedImage img, Insets ins) { int left = ins.left; int right = ins.right; int top = ins.top; int bottom = ins.bottom; g.drawImage(img, 0, 0, left, top, 0, 0, left, top, null); g.drawImage(img, left, 0, comp.getWidth() - right, top, left, 0, img.getWidth() - right, top, null); g.drawImage(img, comp.getWidth() - right, 0, comp.getWidth(), top, img.getWidth() - right, 0, img.getWidth(), top, null); g.drawImage(img, 0, top, left, comp.getHeight() - bottom, 0, top, left, img.getHeight() - bottom, null); g.drawImage(img, left, top, comp.getWidth() - right, comp.getHeight() - bottom, left, top, img.getWidth() - right, img.getHeight() - bottom, null); g.drawImage(img, comp.getWidth() - right, top, comp.getWidth(), comp.getHeight() - bottom, img.getWidth() - right, top, img.getWidth(), img.getHeight() - bottom, null); g.drawImage(img, 0, comp.getHeight() - bottom, left, comp.getHeight(), 0, img.getHeight() - bottom, left, img.getHeight(), null);// ww w. j av a 2s. com g.drawImage(img, left, comp.getHeight() - bottom, comp.getWidth() - right, comp.getHeight(), left, img.getHeight() - bottom, img.getWidth() - right, img.getHeight(), null); g.drawImage(img, comp.getWidth() - right, comp.getHeight() - bottom, comp.getWidth(), comp.getHeight(), img.getWidth() - right, img.getHeight() - bottom, img.getWidth(), img.getHeight(), null); } }