ceklock
ceklock

Reputation: 6352

How to synchronize scrollbars on JavaFX?

There are two TextAreas in my application and I want to make the scrollbars slide synchronized when I move one of the scrollbars. But I can't find a way to do that in JavaFX 2.2.

Upvotes: 3

Views: 1421

Answers (1)

Alexander Kirov
Alexander Kirov

Reputation: 3654

This worked for me:

TextArea ta1 = new TextArea(), ta2 = new TextArea();
ta1.scrollTopProperty().bindBidirectional(ta2.scrollTopProperty());

In common case, you can apply a lookupAll(String) operation at TextArea to find scroll bar inside the TextArea, and bind their values bidirectionally.

Upvotes: 7

Related Questions