Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javafx fxml file TextArea line break and tab in text

How to edit text in the TextArea in `.fxml file as such I can use line breaks and tabs. The Textarea is predefined and can not be edited.

Images to support

FXML File

FXML File

The View

The View

like image 510
Sevi Avatar asked Jan 22 '15 16:01

Sevi


People also ask

How do I add a line to text in JavaFX?

String newLine = "\n"; Append or prepend the new line to your TextArea to create new lines. Save this answer.

How do I make a TextArea not editable in JavaFX?

You can use following statement in order to make text-area object non-editable with auto scrollbar: textAreaObjectName. setEditable(false);

Do you need FXML for JavaFX?

Note that the default project created by IntelliJ uses FXML, so javafx.fxml is required along with javafx.controls . If your project uses other modules, you will need to add them as well.


1 Answers

If you want to directly use the text you can use something :

<TextArea prefHeight="200.0" prefWidth="200.0" text="${'Multi\nLine\tTab'}" />

In case you want to use in Scene Builder, you can switch to multi-line mode.

enter image description here

Switching to multi-line mode, scene builder will insert:

&#10; for \n 
&#9;  for \t
like image 183
ItachiUchiha Avatar answered Sep 22 '22 02:09

ItachiUchiha