简体   繁体   English

如何在FXML文件的多行中布置文本并将其附加

[英]How can I lay out text in multple lines in my FXML File and append them

In one of my FXML file, I have a text tag that look this 在我的一个FXML文件中,我有一个文本标签,看起来像这样

 <TextFlow >
      <Text text="There are 15 questions standing between you and a million dollar pay day! Each question is presented in multiple choice format. One of the four choices is the correct answer - your job is to pick the right one! The questions become more difficult as you progress through the game, but the potential payoff increases as well! Miss a question and the game is over." id="gameText" fill="white"/>
 </TextFlow>

When I tried to do it in multiple lines like this 当我试图像这样多行

<TextFlow >
     <Text text="There are 15 questions standing between you and a million dollar pay day!
     Each question is presented in multiple choice format. One of the four choices is the 
     correct answer - your job is to pick the right one! The questions become more difficult
     as you progress through the game, but the potential payoff increases as well! Miss a 
     question and the game is over." id="gameText" fill="white"/>
</TextFlow>

My output came out like this with the second method(The text tag with multiple lines) 我的输出是通过第二种方法输出的(多行文本标签)

文字问题

The text tag that is a single straight line gives me the correct output but I would like to know if there is another way to layout the text correctly using the second method. 单个直线的文本标签为我提供了正确的输出,但是我想知道是否还有另一种方法可以使用第二种方法正确地布置文本。

As per the answer from here and here using CDATA within your XML may be the solution you are after. 根据从这里这里的答案,在您的XML中使用CDATA可能是您想要的解决方案。

<TextFlow>
    <Text  id="gameText" fill="white">
        <![CDATA[
            There are 15 questions standing between you and a million dollar pay day!<br />
            Each question is presented in multiple choice format. One of the four choices is the correct answer - your job is to pick the right one! The questions become more difficult as you progress through the game, but the potential payoff increases as well!<br />
            Miss a question and the game is over."<br />
        ]]>
    </Text>
</TextFlow>

This will bring back html line breaks within your text node which when rendered by the web browser should give you your desired result 这将在文本节点内带回html换行符,当由网络浏览器渲染时,该换行符将为您提供所需的结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何覆盖文本文件中的行到另一个文件中的特定行,而不是附加它们 - How can I overwrite lines from text file to specific lines in another file instead of appending them 为什么我看不到我的项目中的更改,但我在 fxml 文件中看到了它们? - Why can't I see the changes in my project but I see them in the fxml file? 如何在原始文件中附加文本? - How can I append to my text in raw file? 如何在Swing中最好地布置这些组件? - How can I best lay out these components in Swing? 如何将Java所有行从java控制台输出保存到文本文件并正确附加? - How can I save java all lines from java console output to a text file and properly append it? 如何使用扫描仪类扫描文本文件,挑选某些短语并对其进行计数? - How can I use the scanner class to scan a text file, pick out certain phrases, and count them? 如何以编程方式更改包括 java android 的布局? - How can I programmatically change include lay-out for java android? 如何从fxml文件中的xml文件读取值? - How can I read values from an xml file in a fxml file? 使用Java,如何将文本放置到响应用户键入操作的HTML文本框中? - Using Java how can I lay down text to an HTML textbox that responds to a users keyup action? 如何将自定义类正确导入此FXML文件? - How do I import my custom class correctly into this FXML file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM