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

[macosx] Graphics.fillRect draws to wrong coordinates on Mac with HiDPI display mode

      FULL PRODUCT VERSION :
      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.9


      A DESCRIPTION OF THE PROBLEM :
      It seems that some vector graphics operations like "fillRect" or "drawLine" are not calculated correctly to system coordinates when a HiDPI display mode is used on Mac OS X. The problem does not occur on non HiDPI display modes.

      Start the attached sample and you should notice that the border of the green panel is not drawn on the right and bottom edge of the component.


      REGRESSION. Last worked in version 7u45

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please use the attached sample code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect to see no green gap between the right/bottom borders and the gray frame panel in the background.

      ACTUAL -
      There is a one-pixel gap in green color next to the border drawn with "fillRect".

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package bintools;

      import java.awt.Color;
      import java.awt.Graphics;

      import javax.swing.JFrame;
      import javax.swing.JPanel;

      public class DrawTest2 {
      public static void main(String[] args) {
      JFrame ds_frame = new JFrame();
      ds_frame.setBounds(0, 0, 200, 200);
      ds_frame.setLayout(null);
      JPanel ds_panel = new JPanel() {
      protected void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.drawRect(0, 0, this.getWidth()-1, this.getHeight()-1);
      }
      };
      ds_panel.setBounds(10, 10, 100, 100);
      ds_frame.getContentPane().add(ds_panel);
      ds_panel.setBackground(Color.green);
      ds_frame.setBackground(Color.gray);
      ds_frame.setVisible(true);
      }
      }
      ---------- END SOURCE ----------

            serb Sergey Bylokhov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: