Which listener to use and is there one that works when the user switches to another element? This is necessary in order to verify the correctness of the text input in the TextField field, at the end of the input. Now the method of checking and warning about an error is triggered when the user removes the cursor from the TextField. Jumps out many times, if you hold the cursor after the received alert, which is a bit in the way. You can certainly make a crutch, but if there is another solution to this problem, then I would not want to :) Thanks in advance

    1 answer 1

    Well in FX there is an event to change this state. That is, it works And when you select, And when you remove the selection.

    TextField yourTextField = new TextField(); yourTextField.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) { if (newPropertyValue) { System.out.println("Textfield on focus"); } else { System.out.println("Textfield out focus"); } } }); 

    Code example in impudent slyamzil from here