JavaFx TextArea 提示文本

JavaFx TextArea Prompt Text

我正在尝试让 TextArea 的提示文本以某种格式显示。我能够实现我想要的格式,但它需要我在文本之间添加很多白色 space。我以为 \n 可以解决问题,但事实并非如此。有没有办法在没有 wrapText="true" 和大量白色 space 的情况下让提示文本转到下一行?

<?xml version="1.0" encoding="UTF-8"?>

<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox alignment="TOP_CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" spacing="10.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ez_proxy_2.toolbar_buttons.AddStanzaController">
    <children>
        <StackPane>
            <children>
                <Label alignment="CENTER" maxWidth="1.7976931348623157E308" text="Title">
                    <font>
                        <Font size="28.0" />
                    </font>
                    <padding>
                        <Insets top="10.0" />
                    </padding>
                </Label>
                <FontAwesomeIconView fx:id="faQuestionMark" glyphName="QUESTION_CIRCLE" size="32" StackPane.alignment="CENTER_RIGHT">
                    <StackPane.margin>
                        <Insets right="10.0" />
                    </StackPane.margin>
                </FontAwesomeIconView>
            </children>
        </StackPane>
        <TextField fx:id="tfTitle" alignment="CENTER" promptText="Enter Title Here">
            <VBox.margin>
                <Insets left="20.0" right="20.0" />
            </VBox.margin>
        </TextField>
        <Label alignment="CENTER" maxWidth="1.7976931348623157E308" text="Stanza Info">
            <font>
                <Font size="17.0" />
            </font>
        </Label>
        <TextArea fx:id="taStanzaInfo" promptText="Title Fake Title                                                                                                                                         URL https://www.example.com                                                                                                                     HJ www.example.com                                                                                                                               DJ example.com" wrapText="true">
            <VBox.margin>
                <Insets left="20.0" right="20.0" />
            </VBox.margin>
        </TextArea>
        <Button fx:id="btnOff" mnemonicParsing="false" onAction="#handleBtnOff" prefHeight="25.0" prefWidth="52.0" text="Off" />
        <HBox alignment="CENTER_RIGHT" prefHeight="100.0" prefWidth="200.0" spacing="10.0">
            <children>
                <Button fx:id="btnExit" mnemonicParsing="false" onAction="#handleBtnExit" prefHeight="25.0" prefWidth="52.0" text="Exit" />
                <Button fx:id="btnAdd" mnemonicParsing="false" onAction="#handleBtnAdd" prefHeight="25.0" prefWidth="52.0" text="Add" />
            </children>
            <VBox.margin>
                <Insets left="20.0" right="20.0" />
            </VBox.margin>
        </HBox>
    </children>
</VBox>

您可以尝试对 \r\n - &#13;&#10; 使用 XML 语法(在我的测试示例中,出于某种原因,只是 &#10; 不适用于 promptText 属性,但它与 text):

一起工作正常
<TextArea promptText="Title Fake Title&#13;&#10;URL https://www.example.com&#13;&#10;HJ www.example.com&#13;&#10;DJ example.comButton" />