我有一个 Scrollpane 女巫,在 VBox 中包含几个 TitledPanes。我只想在垂直方向滚动。内容的宽度应限制为 ScrollPane 的宽度。当 TitledPane 的宽度大于 ScrollPane 的宽度时,如何让 TitledPane 剪辑标题?在 TitledPane 将其宽度调整为 Title 宽度的那一刻,与任何 maxWidth、Fit to Width 或类似设置无关。
费边
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="454.0" prefWidth="260.0" xmlns:fx="http://javafx.com/fxml">
<children>
<ScrollPane fitToWidth="true" hbarPolicy="AS_NEEDED" hmax="1.0" pannable="false" prefHeight="200.0" prefViewportWidth="100.0" prefWidth="200.0" vbarPolicy="AS_NEEDED" AnchorPane.bottomAnchor="0.0" AnchorPane. leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<VBox maxWidth="200.0" prefHeight="500.0" prefWidth="480.0" spacing="5.0">
<children>
<TitledPane animated="false" maxWidth="200.0" text="Very long title, should be clipped. Very long title, should be clipped. " textOverrun="CLIP" wrapText="true">
<content>
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="500.0" prefWidth="200.0">
<children>
<ListView prefHeight="500.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</VBox>
</content>
</ScrollPane>
</children>
</AnchorPane>