There was a question that confused me. Adding a comma to the TextField instance at the end of a line puts a comma at the beginning of the output. Although in the observed repository the output order is correct. The situation in the examples is textOut.setText("123,"); in the field will output, 123 But if the ending is covered with any character other than a comma, the result is correct. textOut.setText("123,9"); -> 123.9

UPD:

I will add an example:

 public void start(Stage primaryStage) throws Exception { TextField field = new TextField(); field.setFocusTraversable(false); field.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT); field.setPrefWidth(300); Button button = new Button("magic"); button.setOnAction(e -> { field.setText(field.getText().equals("123,") ? "123,0" : "123,"); }); VBox p = new VBox(field, button); primaryStage.setScene(new Scene(p, 300, 300)); primaryStage.show(); field.setFont(new Font(24.0d)); field.setText("111"); } 

As can be seen from the example, the orientation of the field RIGHT_TO_LEFT is generally the root cause of the behavior not expected.

  • can I describe the playback case in more detail? I can not play - a.chugunov

1 answer 1

The solution to your problem is simple, replace
field.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
on
field.setAlignment(Pos.BASELINE_RIGHT);

You don’t need to target the entire node but just align the text.

  • one
    by morning everything was cleared up) - Peter Slusar