在滚动同时2列表视图 [英] Scroll 2 listview at same time

查看:147
本文介绍了在滚动同时2列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的的JavaFX 的项目,我用2 文本流来显示一些文本。我用 vvalueProperty ScrollPanes 这是持有文本流来无论滚动的TextFlow 在同一时间

In my JavaFX project I was using 2 TextFlows to display some text. I used vvalueProperty of ScrollPanes which are holding the TextFlows to scroll both TextFlow at same time

scrolPane1.vvalueProperty().bindBidirectional(scrolPane2.vvalueProperty());

不过,由于的TextFlow 仅在的Java 8 支持,我试着用的ListView 。
我怎么可以滚动2 列表视图在同一时间?由于的ListView 包含一个内的ScrollPane 我的做法,与TextFlow的工作不能在这里工作。

But since TextFlow is only support in Java 8, Im trying to replace them with ListView. How can I scroll 2 ListViews at same time? Since ListView contains a inner ScrollPane my approach that worked with TextFlow doesn't work here.

只要我想要滚动2 列表视图在同一时间。

Simply I want to scroll 2 ListViews at same time.

推荐答案

试着这么做

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
            }
        }
    }
});

这篇关于在滚动同时2列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆