1

私の 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 スペースにアクセスする際の最終的な優先順位を持つことを望みます。

4

1 に答える 1

1

できるよ

<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 ?>
于 2016-09-21T20:29:31.543 に答える