Luis Averhoff
Luis Averhoff

Reputation: 395

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

 <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)

text problem

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.

Upvotes: 0

Views: 50

Answers (1)

Chris
Chris

Reputation: 637

As per the answer from here and here using CDATA within your XML may be the solution you are after.

<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

Upvotes: 2

Related Questions