如何防止ScrollPane中的VBox中的元素被塞满?

我正在使用一个盒子来记录正在创建的游戏中发生的事件。 为此,我将VBox放入ScrollPane中。此VBox充满了GridPanes,目前仅包含文本。

前几项按预期工作,但是一旦达到盒子的最大高度,它们就会开始塞满。我希望高度随条目增加,而条目不要塞满。

First few entries / Crammed entries

为VBox提供最小的最小高度可以解决此问题,但会使滚动条过小,并且我希望每次添加新条目时该框都滚动到底部。 框的FXML代码:

namespace SwashBuckleexample.Functions.SwaggerFunctions.SwaggerDocumentFilter
{
    public class SwashBuckleexampleDocumentFilter : IDocumentFilter
    {
        public void Apply(OpenApiDocument swaggerDoc,DocumentFilterContext context)
        {
            swaggerDoc.Info.Title = "SwashBuckleexample";
            swaggerDoc.Info.Version = "v1";
            swaggerDoc.Servers = new List<OpenApiServer>() { new OpenApiServer() { Url = "LinkToServer" } };
        }
    }
}

GridPane的JavaFX代码:

<AnchorPane prefHeight="144.0" prefWidth="430.0" style="-fx-background-color: #a1aaa0;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.catan.Controller.LogController">
   <children>
      <ScrollPane id="logScrollPane" fx:id="scrollPane" hbarPolicy="NEVER" prefHeight="144.0" prefWidth="430.0" stylesheets="@style.css">
         <content>
            <VBox fx:id="logsBox" prefWidth="430.0" prefHeight="144.0" />
         </content>
      </ScrollPane>
   </children>
</AnchorPane>
iCMS 回答:如何防止ScrollPane中的VBox中的元素被塞满?

我查看了minHeight为10的GridPane的RowConstraint。增加此数字使GridPanes保持我想要的方式。谢谢亚历克斯!

本文链接:https://www.f2er.com/2218569.html

大家都在问