【发布时间】:2019-03-15 21:42:09
【问题描述】:
我试图让TextArea 的提示文本以某种格式显示。我能够实现我想要的格式,但它需要我在文本之间添加大量空白。我在想\n 会做到这一点,但事实并非如此。有没有办法在没有wrapText="true" 和大量空白的情况下获取提示文本以转到下一行?
<?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>
【问题讨论】:
-
我无法对此进行测试,但由于 FXML 文件是 XML,您可能需要使用 numeric entities 来表示
\n字符(代码点 10):@987654329 @。但是,XML 属性规范化可能会将每个换行符变成一个空格。