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 自动滚动
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 修改 void 函数的输入参数,然后读取 2022-01-01
