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);
}
});
相关文章