在我的 JavaFX
项目中,我使用了 2 个 TextFlows
来显示一些文本。我使用 ScrollPanes
的 vvalueProperty
持有 TextFlows
同时滚动 TextFlow
scrolPane1.vvalueProperty().bindBidirectional(scrolPane2.vvalueProperty());
但由于 TextFlow
仅在 Java 8
中受支持,我试图用 ListView
替换它们。
如何同时滚动 2 个 ListViews
?由于 ListView
包含内部 ScrollPane
,因此我使用 TextFlow 的方法在这里不起作用。
只是我想同时滚动 2 个 ListViews
。
最佳答案
尝试类似的东西
Platform.runLater(new Runnable() {
@Override
public void run() {
Node n = listView1.lookup(".scroll-bar");
if (n instanceof ScrollBar) {
final ScrollBar bar = (ScrollBar) n;
if (bar.getOrientation().equals(Orientation.VERTICAL)) {
// get the second scrollbar of another listview and bind values of them
}
}
}
});
关于java - 同时滚动 2 个 ListView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25886675/