Here you can find the source of drawScaledImage(Graphics graphics, BufferedImage image, int x, int y, int w, int h, int left, int right)
public static void drawScaledImage(Graphics graphics, BufferedImage image, int x, int y, int w, int h, int left, int right)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; import java.awt.image.BufferedImage; public class Main { public static void drawScaledImage(Graphics graphics, BufferedImage image, int x, int y, int w, int h, int left, int right) { int tw = image.getWidth(); int th = image.getHeight(); graphics.drawImage(image, x, y, x + left, y + h, 0, 0, left, th, null);/*www . java2 s. co m*/ graphics.drawImage(image, x + left, y, x + w - right, y + h, left, 0, tw - right, th, null); graphics.drawImage(image, x + w - right, y, x + w, y + h, tw - right, 0, tw, th, null); } }