JavaFx-8 - 同步两个ScrollPanes

时间:2018-03-08 09:37:51

标签: javafx-8

如何在JavaFx-8中同步两个或多个ScrollPanes?无论移动哪个滚动条,每个SrollPane都应该像另一个一样进行更新。

我在这里找到了一个解决方案,但它只能以一种方式运行:

JavaFX ScrollPane - How to use one scrollbar to scroll 2 ScrollPanes?

1 个答案:

答案 0 :(得分:1)

vvalue和/或hvalue属性进行双向绑定:

scrollPane1.hvalueProperty().bindBidirectional(scrollPane2.hvalueProperty());
scrollPane1.hvalueProperty().bindBidirectional(scrollPane3.hvalueProperty());

scrollPane1.vvalueProperty().bindBidirectional(scrollPane2.vvalueProperty());
scrollPane1.vvalueProperty().bindBidirectional(scrollPane3.vvalueProperty());