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

Infinite growth of ImageView and a pane with a border when the ImageView binds its size to the pane

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: openjfx11, openjfx12
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:

      Description

      The following code creates a BorderPane that contains in its center a pane. This pane has a border and contains an ImageView whose fitHeight and fitWidth properties are bound to the pane's height and width. If this pane is a TilePane or a BorderPane, the sizes of the pane and image view will grow indefinitely. Pane and BorderPane are not affected. I did not test other panes.
      Setting a border is crucial to reproduce this bug.

      public class PaneResizeBug extends Application {

      @Override
      public void start(Stage stage) {
      Scene scene = new Scene(new HomeView());
      stage.setScene(scene);
      stage.show();
      }

      public static void main(String[] args) {
      launch(args);
      }
      }

      public class HomeView extends BorderPane {

      HomeView() {
      var pane = new AnchorPane(); // AnchorPane or TilePane bugged, Pane or BorderPane not
      pane.setBorder(new Border(new BorderStroke(Color.RED, null, null, new BorderWidths(5)))); // necessary for the bug

      var imgView = new ImageView();
      imgView.fitWidthProperty().bind(pane.widthProperty());
      imgView.fitHeightProperty().bind(pane.heightProperty());

      imgView.fitWidthProperty().addListener((obs, ov, nv) -> System.out.println("iw " + nv));
      imgView.fitHeightProperty().addListener((obs, ov, nv) -> System.out.println("ih " + nv));
      pane.widthProperty().addListener((obs, ov, nv) -> System.out.println("w " + nv));
      pane.heightProperty().addListener((obs, ov, nv) -> System.out.println("h " + nv));

      pane.getChildren().add(imgView);
      setCenter(pane);
      }
      }

      The output is:

      iw 10.0
      w 10.0
      ih 10.0
      h 10.0
      iw 20.0
      w 20.0
      ih 20.0
      h 20.0
      iw 120.0
      w 120.0
      ih 30.0
      h 30.0
      iw 130.0
      w 130.0
      ih 40.0
      h 40.0
      iw 140.0
      w 140.0
      ih 50.0
      h 50.0
      iw 150.0
      w 150.0
      ih 60.0
      h 60.0
      ...

      There seems to be some circular call when computing the size of the pane.

        Attachments

          Activity

            People

            • Assignee:
              arapte Ambarish Rapte
              Reporter:
              nlisker Nir Lisker
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: