Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 213
khosi khosi Avatar asked Mar 16 '23 00:03

khosi khosi


1 Answers

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.

like image 63
mohsenmadi Avatar answered Mar 27 '23 20:03

mohsenmadi