JavaFX - centered Text in Scene
<p>I've got a JavaFX <code>Text</code>,<code>Scene</code> and <code>Group</code></p>

<pre><code>Text waitingForKey
Scene scene
Group root
</code></pre>

<p>I have a string String <code>waitingForKeyString</code> which I'm adding to <code>waitingForKey</code>and I want to have a center align.</p>

<p>The problem is that sometimes the string has two sentences and I can't aligned it</p>

<pre><code> String waitingForKeyString= " Level 2 \n\n" + "Press ENTER to start a new game";
</code></pre>

<p>OR</p>

<p>String waitingForKeyString= "  Press ENTER \n"+
                            "to start the game", messageString="";</p>

<p>THEN</p>

<pre><code>Scene scene = new Scene(root,SCREEN_WIDTH, SCREEN_HEIGHT, Color.BLACK);
waitingForKey.setText(waitingForKeyString);
root.getChildren().add(waitingForKey);
</code></pre>

<p>So how could I align this to center? When I tried to align first <code>waitingForKeyString</code>I destroyed the second `waitingForKeyString and vicecersa.</p>