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

Graphics.fillRect does not draw when screen scaling is >100 %.

XMLWordPrintable

    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      Tested under Windows 10 version 1803 with a user defined screen scaling of 125 %.

      A DESCRIPTION OF THE PROBLEM :
      Graphics.fillRect does not draw when height value is negative and screen scaling is >100 %.

      The phenomenon is possibly related to Bug JDK-8203470.

      REGRESSION : Last worked in version 8u161

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the code below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Both rectacles should be visible.
      ACTUAL -
      The first rectangle (above abscissa) is invisible.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class InvisibleRectangle extends JFrame {
        public static final long serialVersionUID = 1L;

        public InvisibleRectangle() {
          setSize(400, 300);
          setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
          setVisible(true);
        }


        public static void main(String args[]) {
          SwingUtilities.invokeLater(InvisibleRectangle::new);
        }


        public void paint(Graphics g) {
          g.translate(0, 200);
          g.setColor(Color.BLACK);
          g.drawLine(50,0, 50, -150); // ordinate
          g.drawLine(50,0, 300,0); // abscissa
          g.setColor(Color.BLUE);
          g.fillRect(100,0, 30,-80); // Above abscissa; does not paint.
          g.fillRect(150,0, 30,50); // Below abscissa.
        }

      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: