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

TextAreaSkin: must keep initial scrollTop of area

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx11.0.2, 8u301, jfx16
    • javafx

      the skin doesn't keep the initial setting of area's scrollTop, but resets it to 0.

      To reproduce, run the example below which sets the scrollTop to > 0: on showing the top is 0. Programmatically setting it while showing, behaves as expected.

      public class TextAreaScrollTop extends Application {

          private Parent createContent() {
              TextArea area = new TextArea(LOREM_IPSUM + LOREM_IPSUM);
              area.setWrapText(true);
              // inital value
              area.setScrollTop(100);
             
              Button setScrollTop = new Button("set scrollTop");
              setScrollTop.setOnAction(e -> {
                  area.setScrollTop(100);
              });
              
              // visualize scrollTop
              Label scrollTop = new Label("scrollTop: ");
              Label scrollTopValue = new Label();
              scrollTopValue.textProperty().bind(area.scrollTopProperty().asString());
              VBox content = new VBox(10,
                      new HBox(10, scrollTop, scrollTopValue),
                      area,
                      new HBox(10, setScrollTop));
              return content;
          }

          @Override
          public void start(Stage stage) throws Exception {
              stage.setScene(new Scene(createContent()));
              stage.show();
          }

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

          public final static String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
                  + "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, "
                  + "sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. "
                  + "Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. "
                  + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor "
                  + "invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et "
                  + "accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata "
                  + "sanctus est Lorem ipsum dolor sit amet.";

      }

            Unassigned Unassigned
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: