Java FX TextArea Alignment


Question

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

1
3
1/22/2018 2:17:05 AM

Apply the style to the text child:

.text-area *.text {
    -fx-text-alignment: center;
}
4
3/31/2014 3:42:14 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon