JavaFX - 使 ScrollPane 自动滚动 [英] JavaFX - Make ScrollPane scroll automatically

查看:172
本文介绍了JavaFX - 使 ScrollPane 自动滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ScrollPane 中有一个标签.我正在循环中更新标签(在另一个线程中).如果用户没有将其保持在某个位置,我如何更新 ScrollPane 使其向下滚动(不是横向滚动,这将手动完成)?有二传手吗?

I have a Label inside a ScrollPane. I am updating the label in a loop (In another thread). How can I update the ScrollPane so it scrolls down (not sideways, this will be done manually) if the user doesnt hold it at a position? Is there a setter for it?

推荐答案

感谢@Math,成功了!

@Math thanks , that worked!

@FXML private ScrollPane scroll; //this must match the fx:id of the ScrollPane element or be the scrollpane object
scroll.setVvalue(1.0);           //1.0 means 100% at the bottom

我用这部分代码解决了必须查看选项卡"的问题

And I solved the problem "must be looking at the tab" with this part of code

tab.setOnSelectionChanged(new EventHandler<Event>() {
    @Override
    public void handle(Event arg0) {
        ScrollPane.setVvalue(1.0);
    }        
});

这篇关于JavaFX - 使 ScrollPane 自动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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