假设我的HBox有以下孩子:
<HBox fx:id="hBox" xmlns="http://javafx.com/javafx/8.0.102-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gui.controllers.ChatMessageController">
<children>
<TextFlow>
</TextFlow>
<Label text="|" />
<TextFlow>
</TextFlow>
</children>
</HBox>此HBox的大小可以调整为任何值。如何确保第一个TextFlow始终适合其内容的大小而不进行包装?
换句话说,我希望第一个TextFlow在访问HBox空间时拥有最终的优先级。
发布于 2016-09-22 04:29:32
你可以做到
<HBox fx:id="hBox" xmlns="http://javafx.com/javafx/8.0.102-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gui.controllers.ChatMessageController">
<children>
<TextFlow>
<HBox.hgrow><Priority fx:value="ALWAYS"/></HBox.hgrow>
</TextFlow>
<Label text="|" />
<TextFlow>
<HBox.hgrow><Priority fx:value="ALWAYS"/></HBox.hgrow>
</TextFlow>
</children>
</HBox>显然,您需要添加导入
<?import javafx.scene.layout.Priority ?>https://stackoverflow.com/questions/39625652
复制相似问题