int composite = AlphaComposite.DST;
graphics.setComposite(AlphaComposite.getInstance(composite));
Color c = new Color(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), 0);
graphics.setBackground(bgColor);
graphics.setColor(c);
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
composite = AlphaComposite.DST_OVER;
graphics.setComposite(AlphaComposite.getInstance(composite));
} else {
graphics.setColor(bgColor);
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());