My problem is I have two horizontal scroll bars that I want them to scroll in unison and I\'ve tried using:
bar1.valueProperty().bindBidirectional(bar2.valuePr
Bidi-Binding of valueProperty of a scrollBar in a scrollPane to that of a scrollBar in a tableView is not possible because the former is normalized while the latter is not. Instead, listen to changes and scale manually, like:
protected void bindScrollBarValues(ScrollBar scrollBarInTable, ScrollBar scrollBarInPane) {
// can't use bidi-binding because bar in scrollPane is normalized, bar in table is not
// scrollBarInTable.valueProperty().bindBidirectional(scrollBarInPane.valueProperty());
// scale manually
scrollBarInTable.valueProperty().addListener((src, ov, nv) -> {
double tableMax = scrollBarInTable.getMax();
scrollBarInPane.setValue(nv.doubleValue() / tableMax);
});
scrollBarInPane.valueProperty().addListener((src, ov, nv) -> {
double tableMax = scrollBarInTable.getMax();
scrollBarInTable.setValue(nv.doubleValue() * tableMax);
});
}