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

BackgroundFills overlap each, but still visible with scaled monitor

XMLWordPrintable

    • x86_64
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows 7 Professional (ServicePack 1)
      64 bit
      JAVA_VERSION="11"
      JAVA_VERSION_DATE="2018-09-25"


      A DESCRIPTION OF THE PROBLEM :
      I use a scaled monitor with 150% under Windows 7 (but it also works on Windows 10)

      In the actual program we style a InputField, with single line at the ground. So we have a dark BackgroundFill with zero insets and over that a bright BackgroundFill with one insets for the bottom, but zero for the rest. But under some conditions we see small hairlines on the left, on the top or on the right.

      For the given example we created a Button with a Background and two Fills which overlap each other. If the button is layouted by the Pane everything is fine. But when we move the Button, it is possible to see the underlying Background by small lines at the borders of the Button.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Change your computer to scale the monitor with 150%
      2) Use the given source code
      3) Start the Application
      4) See that the Button is styled correctly. He is fully blue.
      5) Click on the Button -> he will move to another location
      6) In the most cases you will see small lines of the underlying BackgroundFill at the borders (otherwise click again on the button)
       


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The underlying BackgroundFill isn't possible to see.
      ACTUAL -
      Although both BackgroundFills have insets of zero, it is possible to see parts of the underlying Fill.

      Of course it should work if one or more sides have insets of zero.

      ---------- BEGIN SOURCE ----------
      public class BackgroundCheck extends Application {
      private static final BackgroundFill outer = new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY);
      private static final BackgroundFill inner = new BackgroundFill(Color.LIGHTBLUE, CornerRadii.EMPTY, Insets.EMPTY);

      @Override
      public void start(Stage stage) {
      StackPane root = new StackPane();
      root.setBackground(new Background(new BackgroundFill(Color.BLUE, CornerRadii.EMPTY, Insets.EMPTY),
      new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, new Insets(1))));

      Button button = new Button("click me!");
      button.setBackground(new Background(outer, inner));
      button.setOnAction(actionEvent ->
      { double x = Math.random() * 50; button.setTranslateX(x); double y = Math.random() * 50; button.setTranslateY(y); System.out.println(x + " / " + y); }

      );
      root.getChildren().add(button);

      Scene scene = new Scene(root, 300, 300);
      stage.setScene(scene);
      stage.show();
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      We assume that we can solve the problem with borders, but we prefer the backgrounds.

      FREQUENCY : often


            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: