public static void clearImage(BufferedImage image,Color bgColor){
  Graphics2D g2d=(Graphics2D)image.getGraphics();
  g2d.setColor(bgColor);
  g2d.fillRect(0,0,image.getWidth(),image.getHeight());
  g2d.dispose();
}

public static void clearImage ( BufferedImage image , Color bgColor ) { Graphics2D g2d = ( Graphics2D ) image . getGraphics ( ) ; g2d . setColor ( bgColor ) ; g2d . fillRect ( 0 , 0 , image . getWidth ( ) , image . getHeight ( ) ) ; g2d . dispose ( ) ; }
sets the background of the image to the specified color
