title: Why aren't my coordinates matching my JFrame size?
body: <p>I want to do some drawing in a JPanel but the enclosing JFrame size doesn't seem to match where I've asked the coordinates to be drawn.</p>
  <p>In my example code, the JFrame size is set to (700, 700) and the last point is drawn at (600, 600). I would expect this point to be drawn 100 pixels away from the right and bottom edges but it isn't (please see screenshot).</p>
  <p><a href="https://i.stack.imgur.com/CtBvh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CtBvh.png" alt="alt text" /></a></p>
  
  <p>Here's the code I'm using:</p>
  <pre><code>import java.awt.Graphics;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  
  public class Scratch extends JPanel {
  
      static int frameWidth = 700;
      static int frameHeight = 700;
  
      public static void main(String[] args) {
  
      JFrame frame = new JFrame();
  
      frame.setSize(frameWidth, frameHeight);
  
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      Scratch scratch = new Scratch();
  
      frame.getContentPane().add(scratch);
      
      frame.setVisible(true);
  
      }
  
      @Override
      public void paintComponent(Graphics g) {
  
      g.drawRect(100, 100, 1, 1);
  
      g.drawString(&quot;100&quot;, 100, 100);
  
      g.drawRect(200, 200, 1, 1);
  
      g.drawString(&quot;200&quot;, 200, 200);
  
      g.drawRect(300, 300, 1, 1);
  
      g.drawString(&quot;300&quot;, 300, 300);
  
      g.drawRect(400, 400, 1, 1);
  
      g.drawString(&quot;400&quot;, 400, 400);
  
      g.drawRect(500, 500, 1, 1);
  
      g.drawString(&quot;500&quot;, 500, 500);
  
      g.drawRect(600, 600, 1, 1);
  
      g.drawString(&quot;600&quot;, 600, 600);
  
  
      }
  
  }
  </code></pre>