title: Drawing simple bar graph in Java Swing
body: <pre><code>g.fillRect( 70, 250, 20, 144 );
  g.fillRect( 100, 250, 20, 98 );
  </code></pre>
  
  <p>If I use that to draw a bar graph </p>
  
  <p>I get the following result:<br> <br>
  <img src="https://i.imgur.com/9umZYcF.png" alt="enter image description here"></p>
  
  <p>I want the bars to look like:</p>
  
  <p><img src="https://i.imgur.com/pNzdt6P.png" alt="enter image description here"></p>
  
  <p>I know that I can get that result by doing:</p>
  
  <pre><code>g.fillRect( 70, 200-144, 20, 144 );
  g.fillRect( 100, 200-98, 20, 98 );
  </code></pre>
  
  <p>I'm new to Java and I don't really understand whats happening here and how that fixes the problem can someone explain to me why the downside of the bars after the subtraction are aligned?</p>
  
  <p>I know what the four parameters are for. the first 2 are for x, y position and last two are for the width and length. </p>