Unfortunately you can’t do this directly in fxml. The events that can be configured directly in FXML are: setOnAction, Drag & Drop (Drag & Drop), Keyboard, Mouse, Rotation, Swipe and Zoom.
But in your code you can do the following:
public class FXMLDocumentController implements Initializable{
@FXML
// Link entre o controlador e a interface
private TextField idtextfield;
// ... Algum código
public void initialize(URL url, ResourceBundle rb){
/* Adicionando um listener para capturar mudanças de foco
* Obs.: O primeiro componente de cima para baixo normalmente recebe o foco
* da aplicação, então tenha cautela
*/
idtextfield.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
// newValue terá o valor do foco atual, oldValue o valor anterior
// Se estiver com o foco o valor será true
System.out.println(newValue);
}
});
See the full list of events available in FXML looking for: Textfield (Javafx 8)
Thanks for the reply. Unfortunately it was what I feared. Sorry for the inconvenience, as you may have noticed I’m new to this.
– Eduardo Toffolo
One more thing: the link is broken
– Eduardo Toffolo
Sorry, when inserting the label was at the end of the link. Fixed
– Gustavo Fragoso