title: Label moves backwards slowly
body: <p>The code below should move the <code>Label</code> based on the position of the horizontal scroll bar so that the <code>Label</code> appears to remain stationary. This almost works perfectly however when you move the scrollbar to the end the label has moved slightly so it does not look like it is in the same position.</p>
  
  <p><a href="https://i.stack.imgur.com/CNcic.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CNcic.png" alt="enter image description here"></a></p>
  
  <pre><code>import javafx.application.Application;
  import javafx.beans.value.ChangeListener;
  import javafx.beans.value.ObservableValue;
  import javafx.geometry.Insets;
  import javafx.scene.Scene;
  import javafx.scene.control.Label;
  import javafx.scene.control.ScrollPane;
  import javafx.scene.layout.VBox;
  import javafx.stage.Stage;
  
  public class LblMoves extends Application {
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) {
          try {
              VBox images = new VBox();
              images.setPadding(new Insets(0, 0, 0, 0));
              Label posLbl = new Label("0");
  
              images.getChildren().add(posLbl);
  
              images.setPrefSize(Integer.MAX_VALUE, 50);
              ScrollPane scrollPane = new ScrollPane(images);
              scrollPane.setStyle("-fx-background: #FFFFFF;");
  
              scrollPane.hvalueProperty().addListener(new ChangeListener&lt;Number&gt;() {
                  public void changed(ObservableValue&lt;? extends Number&gt; ov, Number old_val, Number new_val) {
                      double screenPer = scrollPane.getHvalue() * scrollPane.getWidth();
                      double pos = scrollPane.getHvalue() * images.getWidth();
                      double marg = pos - screenPer;
                      posLbl.setPadding(new Insets(0, 0, 0, marg));
                  }
              });
  
              Scene scene = new Scene(scrollPane, 600, 600);
              primaryStage.setScene(scene);
              primaryStage.setMaximized(true);
  
              primaryStage.show();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>