khosi khosi
khosi khosi

Reputation: 53

JavaFX TextArea right alignment

I tried to use the TextArea component to let user write multi-line text, but the problem that I can't set the text alignment to right. By default it starts in the left.

The text will be in Hebrew or Arabic, so I need the user to write in the TextArea from right to left. I didn't find from the TextArea code and docs a way to do that, and in some forums some people said it can't be done. Is that true?

Upvotes: 5

Views: 5173

Answers (1)

mohsenmadi
mohsenmadi

Reputation: 2377

If you are using Scene Builder to build the FXML, then simply set Node Orientation property to RIGHT_TO_LEFT. You should see the result as soon as you run "Preview -> Show Preview in Window", where the cursor and typing happen on the righthand side.

If you are creating the TextArea inside a JavaFX application (no FXML), you use the method setNodeOrientation() on your TextArea object with the enum parameter NodeOrientation.RIGHT_TO_LEFT.

Upvotes: 8

Related Questions