因爲我需要一次有多個可摺疊的TitledPanes(默認的JavaFX Accordion不支持),所以我在VBox中添加了一些TitledPanes。到目前爲止,這工作正常,但我意識到TitledPanes的寬度比實際的VBox的寬度小10px。帶有標題欄的VBox的JavaFX填充
繼FXML代碼:
<Pane prefHeight="700.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8.0.71" xmlns:fx="http://javafx.com/fxml/1">
<children>
<VBox prefHeight="700.0" prefWidth="1000.0">
<children>
<TitledPane animated="false" text="Pane 1">
<content>
<AnchorPane prefHeight="300.0" />
</content>
</TitledPane>
<TitledPane animated="false" text="Pane 2">
<content>
<AnchorPane prefHeight="300.0" />
</content>
</TitledPane>
</children>
</VBox>
</children>
</Pane>
該css代碼:
VBox {
-fx-padding: 0 -11 0 -1;
}
對我來說,這個解決方案工作正常,但它看起來像一個糟糕的解決方法。我想那裏需要更聰明的解決方案?!
感謝很多提前:)
謝謝,原來如此! ;-) – pixelstuermer