title: Basic Java Graphics and coordinates not working properly
body: <p>I've done quite a bit with the acm graphics library in the past and I've just begun working on the breakout problem that Stanford assigns. One of the issues which I've had several times in the past with graphics is the coordinates do not accurately reflect where the shapes are actually appearing although I've double and triple checked them. In the end, for those assignments I ended up eyeballing it and making modifications until it look kind of right. So obvious I'm missing something here cause a simple graphics program should not be this difficult.</p>
  
  <p>For example, using acm.graphics my code looks like this.</p>
  
  <pre><code>public static final int APPLICATION_WIDTH = 400;
  public static final int APPLICATION_HEIGHT = 600;
  
  public void setupBorder(){
      // **Sets Black Background
      GRect b = new GRect(0,0,400,600);  //** Sets Black Background
      fillObj(b,Color.black);
      add(b);
  
      //**Sets White Square so border is 5 pixels wide on each side
      b = new GRect(5,5,APPLICATION_WIDTH-10,APPLICATION_HEIGHT-10);
      fillObj(b,Color.white);
      add(b);
      }
  </code></pre>
  
  <p>So my thinking here, is its moved 5 pixels right and 5 pixels down I need to subtract those and then an extra 5 pixels to have a border 5 pixels on each side (basic 2b+x = 1 side, 2a+y= vertical side). You would think this creates a black border 5 pixels on each side with a white square in the middle, but it doesn't. It creates a border on the left, right, and top side of the window but not the bottom. So with something this simple, what can possibly go wrong? I've double, triple, even quad checked the calculations on paper and it should be a white square in the middle with a 5 pixel black border, but it isn't. I've tried changing pixels for percentages, with worse effect. Manually editing the box till it looks close at about -35 for the Yvalue although that's just a bit too far. Anyone have an idea about what's going wrong?</p>
  
  <p><a href="https://i.stack.imgur.com/Qo9Vg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qo9Vg.jpg" alt="appwindow"></a>
  </p>
  
  <p><a href="https://see.stanford.edu/materials/icspmcs106a/Assignment3.zip" rel="nofollow noreferrer">Breakout</a> with these changes made to run and other methods within class.</p>
  
  <pre><code>public void run() {
      /* You fill this in, along with any subsidiary methods */
      init();
  }
  
  public void init(){
  
      setupBorder();
  
  
  }
  
  public void setupBorder(){
      //**Black Background
      GRect b = new GRect(0,0,400,600);  //**Black Background
      fillObj(b,Color.black);
      add(b);
  
      b = new GRect(5,5,APPLICATION_WIDTH-10,APPLICATION_HEIGHT-10);
      fillObj(b,Color.white);
      add(b);
  }
  
  public void fillObj(GFillable a, Color argC)
  {
      a.setFillColor(argC);
      a.setFilled(true);
  }
  </code></pre>