14 Replies Latest reply: Jun 3, 2011 11:42 PM by EJP RSS

    How do I change the background color of a BufferedImage?

    s3a
      I have a program and basically what I am doing is drawing on a BufferedImage object and then painting that BufferedImage object onto the panel. By default, the background is black and it draws in white. I am easily able to change the colour for drawing by doing g2.setColor(Color.RED) for example where g2 is the Graphics2D object created by image.createGraphics(). I tried g2.setBackground(Color.WHITE) and that did not work.

      If more information is needed, just ask.

      Any help in changing the background colour of the BufferedImage would be greatly appreciated!
      Thanks in advance!