title: How can I either reset the coordinates of this Buffered Image or put this Buffered Image in the rectangle?
body: <p>I imported this "troll face" into my code as my enemy which rains from top of the screen to the bottom. But before doing so I created the pink rectangles so that I can overlay the troll face image on top of the rectangles. However, when I set the coordinates of the image equal to the rectangle, you can see that it did not center. I then set one troll face image's coordinate equal to (0,0) and you can see that it is clearly far away from the origin.</p>
  
  <p>I tried to import a different PNG image but in vain and it did not work.</p>
  
  <pre><code>import java.util.LinkedList;
  import java.util.concurrent.TimeUnit;
  import java.awt.Graphics2D;
  import java.awt.Rectangle;
  import java.awt.event.ActionEvent;
  import java.awt.event.MouseEvent;
  import java.awt.image.BufferedImage;
  import java.util.ArrayList;
  public class magazinerain extends GameDriverV4{
      LinkedList&lt;rainingenemies&gt; r = new LinkedList&lt;rainingenemies&gt;();
      rainingenemies variable;
      BufferedImage trollface;
  
      public magazinerain() {
          trollface = this.addImage("minion.png");
      }
      public void faller(Graphics2D win) {
          for (int i = 0; i&lt;r.size(); i++) {
              variable=r.get(i);
              variable.fall(win);
              if (variable.getY()&gt;=800) {
                  delete(variable);
              }
  
          }
      }
  
      public void draw(Graphics2D win) {
          int count = 0;
          win.drawImage(trollface, 0, 0,null);
          for (int i = 0; i &lt; r.size(); i++) {
              variable = r.get(i);
              variable.fall(win);
              //win.drawImage(trollface, (int) variable.getX(), (int) variable.getY(),null);
              //the images are not correctly centered on the screen
              //win.drawImage(trollface, 400, 400,null);
          }
      }
      public void memorymanagement() {
          for (int i = 0; i &lt; r.size(); i++) {
              variable = r.get(i);
              //System.out.println(variable.getY());
              if (variable.getY()&gt;=800) {
                  r.remove(i);
                  //System.out.println("Removed");
              }
  
          }
      }
  
      public void checkintersects(int a, int b) {
          int buffer = 10;
          int buffery = 15;
          for (int i = 0; i&lt; r.size(); i++) {
              variable  = r.get(i);
              //if (a&gt;(variable.getX()-buffer) &amp;&amp; (a&lt;variable.getX()+buffer)) {
              if ((variable.getX()&gt;a-buffer-10)&amp;&amp; (variable.getX()&lt;a+buffer+30)) {
                  //if ((b&gt;variable.getY()-buffery) &amp;&amp; (b&lt;variable.getX()+buffery)) {
                  if ((variable.getY()&gt;b-buffery) &amp;&amp; (variable.getY()&lt;b+buffery)){
                      r.remove(i);
                      System.out.println("spacex="+a+"getx="+variable.getX());
                      System.out.println("spacey="+b+"gety="+variable.getY());
  
                  }
              }
  
          }
      }
  
      public void delete(rainingenemies a) {
          r.remove(a);
      }
      public void insert(rainingenemies a) {
          r.add(a);
      }
      @Override
      public void actionPerformed(ActionEvent e) {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void mouseClicked(MouseEvent e) {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void mousePressed(MouseEvent e) {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void mouseReleased(MouseEvent e) {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void mouseEntered(MouseEvent e) {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void mouseExited(MouseEvent e) {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>Specifically in this code, I expected the troll face to be at (0,0) but it is not there as shown in the screenshot</p>
  
  <p><img src="https://i.stack.imgur.com/mQQQa.png" alt="enter image description here"></p>