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

TranslateTransition - when binding fromXProperty it may not be updated.

XMLWordPrintable

      When trying to make a Text Node scroll across the screen (from right to left) using the TranslationTransition I wanted to bind the fromXProperty so everytime the user resized the screen the Text node would start "fromXProperty". It seems to restart exactly where the window width was originally as opposed to the new width when the user resizes it (further to the right).
      So, the question is "Once you begin to invoke play() is the fromXProperty set and can not be changed?"

      Attached is the full test.
      To reproduce:
      1) resize after the text scrolls off the screen to the left.
      2) observe the where the text starts again.


              Text news = TextBuilder.create()
                      .text("JavaFX 2.0 hello there this is a news ticker | :)")
                      .translateY(18)
                      .fill(Color.WHITE)
                      .build();
              
              final TranslateTransition ticker = TranslateTransitionBuilder.create()
                      .node(news)
                      .duration(Duration.millis(15000))
                      .fromY(19)
                      .interpolator(Interpolator.LINEAR)
                      .cycleCount(Timeline.INDEFINITE)
                      .build();
              
              DoubleProperty fromXProperty = new SimpleDoubleProperty();
              fromXProperty.bind(scene.widthProperty());
              fromXProperty.addListener(new ChangeListener<Number>() {
                  public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                              System.out.println("new fromXProperty: " + newValue);
                          }
              });
              ticker.fromXProperty().bind(fromXProperty);

            mheinrichs Michael Heinrichs (Inactive)
            cdea Carl Dea
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: