title: overlay images in java
body: <p>I hope you can give me some advices to solve my problem.
  I need to overlay many images on a button.but the problem is, 
  this is the base image (tooth): (http://i.imgur.com/7tIcP.gif)</p>
  
  <p>my first image is this:
  <a href="http://i.imgur.com/FYuD8.gif" rel="nofollow">http://i.imgur.com/FYuD8.gif</a>
  and then I put this:
  <a href="http://i.imgur.com/mWz9c.gif" rel="nofollow">http://i.imgur.com/mWz9c.gif</a>
  the first image overlaps the second so I just can see only the second image...</p>
  
  <p>maybe you will tell me that one option is change the order of the image before overlay, but the user will select what will be the first, maybe just want the first image, but in other cases user will put the first AND then the second or vice versa...</p>
  
  <p>my code is this:</p>
  
  <pre><code>    BufferedImage large=null;
      large = ImageIO.read(new File("firstimage.gif"));
  
      BufferedImage small=null;
  
      small = ImageIO.read(new File("secondimage.gif"));
  
      int w = Math.max(large.getWidth(), small.getWidth());
      int h = Math.max(large.getHeight(), small.getHeight());
  
      BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
  
      // paint both images, preserving the alpha channels
      Graphics g = combined.getGraphics();
      g.drawImage(large, 0, 0, null);
      g.drawImage(small, 0, 0, null);
  
      ImageIO.write(combined, "PNG", new File("twoInOne.png"));
  
      ImageIcon icon1 = new ImageIcon(combined);
      jbutton1.setIcon(icon1);
  </code></pre>
  
  <p>Maybe is a format of the images issue, or my code, but I prefer that you guys can help me with this problem thank you.  </p>
  
  <p>Now I uploaded the 3 images: I skip the base image (tooth) cause I dont think it will be the problem in there.</p>