gpt4 book ai didi

java - ScrollPane 不允许向下滚动查看其内容

转载 作者:行者123 更新时间:2023-11-30 02:30:46 27 4
gpt4 key购买 nike

我有一个 VBox,我已向其中添加了 50 个标签。考虑到它包含在 ScrollPane 中,我认为它允许我向下滚动以查看其余数据,但它不允许这样做。

当我通过场景生成器构建它时,它被配置为 XML。

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="454.0" prefWidth="641.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<children>
<VBox layoutX="111.0" layoutY="96.0" prefHeight="262.0" prefWidth="100.0">
<children>
<Label contentDisplay="TOP" style="-fx-font-size: 20;" text="Stack" />
<VBox fx:id="stackBox" alignment="BOTTOM_LEFT" prefHeight="284.0" prefWidth="149.0" style="-fx-border-color: black; -fx-background-color: lightgrey;" />
</children>
</VBox>
<VBox layoutX="298.0" layoutY="47.0" prefHeight="379.0" prefWidth="198.0">
<children>
<Label style="-fx-font-size: 20;" text="Heap" />
<ScrollPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="341.0" prefWidth="202.0" vbarPolicy="ALWAYS">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0">
<children>
<VBox fx:id="heapBox" prefHeight="284.0" prefWidth="149.0" style="-fx-border-color: black; -fx-background-color: lightgrey;" />
</children>
</AnchorPane>
</content>
</ScrollPane>
</children>
</VBox>
</children>
</AnchorPane>

目前的样子: enter image description here

由于 VBox 中有 50 个元素,它应该允许我向下滚动以查看剩余的 32 个元素,但可以看出,滚动条不允许这样做。

遇到这种情况该怎么办?

最佳答案

ScrollPane 内的 AnchorPane 中删除 minpref 大小值。然后您的 AnchorPane 就可以适合 ScrollPane 内容。

<AnchorPane>
<children>
<VBox fx:id="heapBox" prefHeight="284.0" prefWidth="149.0" style="-fx-border-color: black; -fx-background-color: lightgrey;" />
</children>
</AnchorPane>

关于java - ScrollPane 不允许向下滚动查看其内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44323398/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com