【问题标题】:Scroll 2 listview at same time同时滚动 2 个列表视图
【发布时间】:2014-11-11 06:14:10
【问题描述】:

在我的 JavaFX 项目中,我使用 2 TextFlows 来显示一些文本。我使用了 ScrollPanes 中的 vvalueProperty 来同时滚动 TextFlowsTextFlow

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

但由于TextFlow 仅支持Java 8,我试图用ListView 替换它们。 如何同时滚动 2 个ListViews?由于ListView 包含一个内部ScrollPane,因此我使用TextFlow 的方法在这里不起作用。

我只想同时滚动 2 个ListViews

【问题讨论】:

    标签: java listview javafx


    【解决方案1】:

    试试类似的东西

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

    【讨论】:

      猜你喜欢
      • 2013-01-21
      • 1970-01-01
      • 2019-12-10
      • 2011-12-17
      • 2016-07-25
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多