JavaFX - 使ScrollPane自动滚动 [英] JavaFX - Make ScrollPane scroll automatically
本文介绍了JavaFX - 使ScrollPane自动滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ScrollPane中有一个Label。我在循环中更新标签(在另一个线程中)。如果用户不将其保持在某个位置,我如何更新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屋!
查看全文