title: clearRect draws black instead of transparent
body: <p>It seems like <code>clearRect</code> doesn't set my <code>BufferedImage</code> to transparent but to black. Creating a <code>new BufferedImage</code> works, but I don't want to produce too much garbage.
  I have this code for my chess programm:</p>
  
  <pre><code>//graphics
  private Graphics2D g2d;
  
  private Graphics2D gLayer1;
  private Graphics2D gLayer2;
  private Graphics2D gLayer3;
  
  public BufferedImage imgLayer1;
  private BufferedImage imgLayer2;
  private BufferedImage imgLayer3;
  
  private Game() throws IOException {
  
      //initialize...
  
      imgLayer1 = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
      gLayer1 = imgLayer1.createGraphics();
  
      imgLayer2 = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
      gLayer2 = imgLayer2.createGraphics();
  
      imgLayer3 = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
      gLayer3 = imgLayer3.createGraphics();
  }
  
  //main
  public static void main(String[] args) throws IOException {
  
      //initialize frame
  }
  
  public void run() {
  
      while (isRunning) {
  
          updateGraphicsLayer1();
          updateGraphicsLayer2();
          updateGraphicsLayer3();
  
          repaint();
      }
  }
  
  protected void paintComponent(Graphics g) {
      g2d = (Graphics2D) g;
  
      g.drawImage(imgLayer1, 0, 0, null);
      g.drawImage(imgLayer2, 0, 0, null);
      g.drawImage(imgLayer3, 0, 0, null);
  
      g2d.dispose();
  }
  
  public void updateGraphicsLayer1() {
      if (redrawLayer1) {
  
          gLayer1.clearRect(0, 0, WIDTH, HEIGHT);
  
          //draw this layer
      }
  }
  
  public void updateGraphicsLayer2() {
      if (redrawLayer2) {
  
          gLayer2.clearRect(0, 0, WIDTH, HEIGHT);
  
          //draw this layer
      }
  }
  
  public void updateGraphicsLayer3() {
      if (redrawLayer3) {
  
          gLayer3.clearRect(0, 0, WIDTH, HEIGHT);
  
          //draw this layer
      }
  }
  </code></pre>
  
  <p>this is what I get:</p>
  
  <p><a href="https://i.stack.imgur.com/RDRq5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RDRq5.png" alt="enter image description here"></a></p>
  
  <p>what have I got to do?
  How can I clear my layers, so they are transparent?</p>