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

GUI seems not to be refreshed properly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • None
    • 8u5
    • javafx
    • Windows 7 x64, JDK 8

    Description

      I use the new released Java 8 Version with JavaFX8. It seems, that if the minwidth property of an HBox is binded to another property and you change the value of the property to another value, the GUI is not refreshed properly.

      I made a little program to show my problem.

      public class Main extends Application{

      DoubleProperty widthProperty;

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

      }

      @Override
      public void start(Stage primaryStage){
      HBox root = new HBox();
              HBox root2 = new HBox();
              HBox root3 = new HBox();
              HBox root4 = new HBox();

              Scene scene = new Scene(root, 1600, 800);

              primaryStage.setScene(scene);
              primaryStage.show();

              widthProperty = new SimpleDoubleProperty(400);

              root2.setPrefSize(400, 400);
              root3.setPrefHeight(400);
              root3.minWidthProperty().bind(widthProperty);
              root4.setPrefSize(400, 400);

              root2.setStyle("-fx-background-color: green");
              root3.setStyle("-fx-background-color: red");
              root4.setStyle("-fx-background-color: yellow");

              root2.setOnMouseClicked(new EventHandler<MouseEvent>() {
                  @Override
                  public void handle(MouseEvent event) {
                      root2.setMinWidth(600);
                  }
              });

              root2.widthProperty().addListener(new ChangeListener<Number>() {

                  @Override
                  public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
      // Platform.runLater(new Runnable() {
      // @Override
      // public void run() {
      // widthProperty.set((Double) newValue);
      // }
      // });

                  widthProperty.set((Double) newValue);
              }
          });

          root.getChildren().addAll(root2, root3, root4);
      }
      }

      So there are 3 HBoxs in a HBox root. If i click on root2, the width of it is changed. So the changelistener detects it and change the value of the property. Now the minwidth of the root3 should be changed due to the binded widthProperty. But the GUI is not updated. It shows the old width.

      Now if i click the second time on root2, the GUI is updated properly, it shows the new width of root3.

      If i do this with Platform.runlater (comment block), the GUI is also updated properly. This issue didn't occured with Java 7.

      Attachments

        Activity

          People

            msladecek Martin Sládeček
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: