Use the method that comes with TextField under JavaFX:
setAlignment(Pos.CENTER_RIGHT)
Example: a loan calculator program
If this sentence is not added, the default is left to right
After removing the comment
Well, that solves the problem~