Here you can find the source of drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)
public static void drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; import java.awt.Insets; import java.awt.Rectangle; import javax.swing.ImageIcon; public class Main { public static void drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter) /* */{// ww w . j a v a 2s.c o m /* 2894 */int left = ins.left; /* 2895 */int right = ins.right; /* 2896 */int top = ins.top; /* 2897 */int bottom = ins.bottom; /* 2898 */int x = rect.x; /* 2899 */int y = rect.y; /* 2900 */int w = rect.width; /* 2901 */int h = rect.height; /* */ /* 2904 */g.drawImage(img.getImage(), x, y, x + left, y + top, 0, 0, left, top, null); /* */ /* 2906 */g.drawImage(img.getImage(), x + left, y, x + w - right, y + top, left, 0, img.getIconWidth() - right, top, null); /* */ /* 2908 */g.drawImage(img.getImage(), x + w - right, y, x + w, y + top, img.getIconWidth() - right, 0, img.getIconWidth(), top, null); /* */ /* 2912 */g.drawImage(img.getImage(), x, y + top, x + left, y + h - bottom, 0, top, left, img.getIconHeight() - bottom, null); /* */ /* 2914 */g.drawImage(img.getImage(), x + left, y + top, x + w - right, y + h - bottom, left, top, img.getIconWidth() - right, img.getIconHeight() - bottom, null); /* */ /* 2916 */g.drawImage(img.getImage(), x + w - right, y + top, x + w, y + h - bottom, img.getIconWidth() - right, top, img.getIconWidth(), img.getIconHeight() - bottom, null); /* */ /* 2920 */g.drawImage(img.getImage(), x, y + h - bottom, x + left, y + h, 0, img.getIconHeight() - bottom, left, img.getIconHeight(), null); /* */ /* 2922 */g.drawImage(img.getImage(), x + left, y + h - bottom, x + w - right, y + h, left, img.getIconHeight() - bottom, img.getIconWidth() - right, img.getIconHeight(), null); /* */ /* 2924 */g.drawImage(img.getImage(), x + w - right, y + h - bottom, x + w, y + h, img.getIconWidth() - right, img.getIconHeight() - bottom, img.getIconWidth(), img.getIconHeight(), null); /* */ /* 2927 */if (drawCenter) /* 2928 */g.drawImage(img.getImage(), x + left, y + top, x + w - right, y + h - bottom, left, top, img.getIconWidth() - right, img.getIconHeight() - bottom, null); /* */} }