Here you can find the source of setBackgroud(BufferedImage image, Color backgroundColor)
public static BufferedImage setBackgroud(BufferedImage image, Color backgroundColor)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; public class Main { public static BufferedImage setBackgroud(BufferedImage image, Color backgroundColor) { Graphics2D g2d = image.createGraphics(); g2d.setPaint(backgroundColor);/*ww w.ja va2s. co m*/ g2d.fillRect(0, 0, image.getWidth(), image.getHeight()); g2d.dispose(); return image; } }