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

[TextArea] scrollToTop is not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx13, 8u25, jfx17
    • javafx
    • Windows 7 64bits

      Run this test app :

      "

      import javafx.application.Application;
      import static javafx.application.Application.launch;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.control.TextArea;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class testTextArea extends Application {

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

          @Override
          public void start(Stage primaryStage) throws Exception {
              StringBuilder string = new StringBuilder();
              for (int i = 0; i < 5000; ++i) {
                  string.append("This is a very long text in order to test something.").append(i).append("\n");
              }

              HBox box = new HBox();

              Scene scene = new Scene(box);
              primaryStage.setScene(scene);
              primaryStage.show();

              TextArea textArea = new TextArea(string.toString());

              box.getChildren().add(textArea);
              textArea.scrollTopProperty().addListener(new ChangeListener<Number>() {

                  @Override
                  public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                      System.out.println(newValue);
                  }
              });
              textArea.setScrollTop(1000);
          }
      }
      "

      You will see that the call to setScrollTop is not working because the method "scrollBoundsToVisible" in TextAreaSkin is being called afterwards setting a new scrollTop value to 0.

            Unassigned Unassigned
            shadzic Samir Hadzic
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Imported: