As you can see on the picture the text alignment for each colum is set to left alignment. Is there any way to change this? So far I've tried within my CSS file:
#Cols{
text-align: right;
}
I have also tried:
#Cols{
-fx-text-alignment: right;
}
Does anyone know how I can change the alignment to right?
Best Answer
Alignment of all table columns:
Starting from JavaFX-8, you can use newly defined CSS selector
table-column
,For JavaFX-2, To achieve this define a CSS selector:
and set the id of the tableview.
Alignment of single table column:
Starting from JavaFX-8, you can apply the styling directly to
TableColumn
,or with css,
where
For JavaFX-2,
To apply different alignments to different columns you need to set cell factory for that column. For instance assume that the 1st column in your table should be aligned to the left while other columns use the table's default alignment (
CENTER-RIGHT
in your case).