JavaFX - Make ScrollPane scroll automatically(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 自动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JavaFX - 使 ScrollPane 自动滚动


基础教程推荐
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01