我正在尝试在JavaFX中的TextFlow中显示文本。它没有显示任何内容,我不确定为什么这不起作用。我在我的视图中添加了一个TextFlowid,并尝试在控制器中添加一些文本。
控制器:
public class LoggingTabController
{
@FXML
private TextFlow tflow;
@FXML
public void initialize()
{
Text text1 = new Text("asd");
Text text2 = new Text("Some Text");
tflow.getChildren().addAll(text1, text2);
}
}
查看:
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<columnConstraints>
<ColumnConstraints maxWidth="1.7976931348623157E308" percentWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="535.0" minHeight="484.0" prefHeight="515.0" />
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="0.0" prefHeight="20.0" vgrow="ALWAYS" />
<RowConstraints maxHeight="0.0" minHeight="0.0" prefHeight="0.0" />
</rowConstraints>
<children>
<TabPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" tabClosingPolicy="UNAVAILABLE" GridPane.rowIndex="1" />
<HBox minHeight="-Infinity" minWidth="-Infinity" GridPane.rowIndex="1">
<children>
<Button fx:id="Button_Update" mnemonicParsing="false" prefHeight="77.0" prefWidth="134.0" text="Select All" />
<Button fx:id="Button_SelectAll" mnemonicParsing="false" prefHeight="77.0" prefWidth="167.0" text="Copy to Clipboard" />
<Button fx:id="Button_Update1" mnemonicParsing="false" prefHeight="77.0" prefWidth="159.0" text="Save Log to File" />
</children>
</HBox>
<ScrollPane prefHeight="600.0" prefWidth="449.0">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="567.0" prefWidth="511.0">
<children>
<TextFlow id="tFlow" fx:id="tFlow" layoutX="-1.0" layoutY="1.0" prefHeight="567.0" prefWidth="511.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children></AnchorPane>
</content>
</ScrollPane>
</children>
</GridPane>
为什么它没有显示任何内容?