我使用以下代码打印滚动窗格及其可见内容的边界:
Bounds scrollBounds = scrollPane.localToScene(scrollPane.getBoundsInParent());
System.out.println("ScrollPane Bounds: " + scrollBounds);
if (scrollPane.getContent() instanceof Parent)
{
Node n = (Node)scrollPane.getContent();
Bounds contentBounds = n.localToScene(n.getBoundsInParent());
System.out.println("Content Bounds: " + contentBounds);
}
它给出了followint输出:
ScrollPane Bounds: BoundingBox [minX:1.0, minY:30.0, minZ:0.0, width:862.0, height:505.0, depth:0.0, maxX:863.0, maxY:535.0, maxZ:0.0]
Content Bounds: BoundingBox [minX:2.0, minY:6.0, minZ:0.0, width:989.0, height:1296.0, depth:0.0, maxX:991.0, maxY:1302.0, maxZ:0.0]
如果观察滚动窗格及其内容的minY,则scrollPane内容的开始位于滚动窗格本身开始之前24个单位。(虽然滚动窗格的Vvalue = 0,表示滚动酒吧在顶部)。
内容的最小值也随着大小而变化 窗口。(当窗口大小最小时,它是0,当最大化时,它是 大约20)
怎么可能?或者我是否以错误的方式接受了界限?