How can I add a line break to a button's text when using the Scene Builder? Doing it in the controller's code (of the Java file) gives me what I want:
button.setText("one\ntwo");
results in
one
two
being displayed. But inserting one\ntwo
into the button's text when using Scene Builder (and without the Java code mentioned above) results in one\ntwo
being displayed.
There is a "Wrap Text" checkbox with which I was unsuccessful. I guess this is for making the text wrap when the button is not wide enough, but this is not the desired behavior.
On Scene Builder, you can switch to multi-line mode, and start adding text and new lines.
With your text:
Then, if you edit the FXML file you will see that the usual line return \n
is replaced with the html encoding for line feed:
. So in your case:
<Button fx:id="button" text="one two" />