Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8066193

Drawing Rectangle in Java 8 Shows Pixel Anomaly. Prior version 7 is OK

XMLWordPrintable

    • 2d
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      Java Version 8

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 Professional 64 BIT

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Lenovo Thinkpad T440

      A DESCRIPTION OF THE PROBLEM :
      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

      http://stackoverflow.com/questions/22058987/drawing-rectangle-in-java-shows-pixel-anomaly?rq=1

      ADDITIONAL REGRESSION INFORMATION:
      Any version prior to Version 8 works, at least with my Lenovo Thinkpad T440


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please refer to source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I was expecting to see a closed Rectangle
      ACTUAL -
      The rectangle is off by one pixel on the bottom right and bottom left (looks like an off-by-one pixel bug). Please fix this as it was working in prior version

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      None ... See link for screenshot

      http://stackoverflow.com/questions/22058987/drawing-rectangle-in-java-shows-pixel-anomaly?rq=1

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      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();
              }
          }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      draw rectangle with individual lines

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: