title: Drawing Rectangle in Java Shows Pixel Anomaly
body: <p>I have a very simple java program that draws a rectangle but when I closely examine the rendered shape, I see two extra pixels that shouldn't be there ...</p>
  
  <p><img src="https://i.stack.imgur.com/yXuJy.png" alt="enter image description here">
  You can see one extra pixel at below left and one at below right.</p>
  
  <p>I am using Windows 7 Professional 64-BIT using JDK 1.8.0.   Here is the program ...</p>
  
  <pre><code>    import java.awt.Graphics;
      import java.io.IOException;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
  
      public class JavaBug {
  
      public JavaBug() throws IOException {
          JFrame frame = new JFrame();        
          frame.add( new JPanel() {
          private static final long serialVersionUID = 1L;
  
                  public void paintComponent( Graphics g ) {
                      super.paintComponent(g);
                      g.drawRect(50, 50, 20, 20); 
                  }
              });
  
              frame.setSize(400, 300);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible( true );
          }
  
          public static void main(String [] args) throws IOException {
              new JavaBug();
          }
      }
  </code></pre>