Java FX TextArea Alignment

java, javafx, javafx-2, textarea

Solution

Apply the style to the text child:

.text-area *.text {
    -fx-text-alignment: center;
}

Problem

I want to display a text inside a Java FX Text area. My code is: ``` TextArea txt = new TextArea(); txt.setEditable(false); txt.setStyle("-fx-font-alignment: center"); txt.setText(text); ``` But I'm not able to set a text alignment (inside the `TextArea`) I tried this: ``` txt.setStyle("-fx-font-alignment: center"); ``` But it didn't work

Original source