JavaFX Enter by TAB

1

Does anyone know how to change the focus with the enter key instead of tab using JavaFX. I already researched a lot and I do not think anything about. Only in Java.

Please can anyone please do it already?

    
asked by anonymous 16.04.2016 / 15:25

2 answers

1

You can do this:

textfield1.setOnKeyPressed( (keyEvent) -> {  
    if(keyEvent.getCode() == KeyCode.ENTER)
        textfield2.requestFocus();  
} );
    
17.04.2016 / 14:12
-1

Hi, you can use this method, you have to pass a TextField list of the form, with the order in which you want the focus to happen.

public void setNextFocus(TextField... texFiels) {

    for (TextField txt : texFiels) {
        txt.setOnAction(event -> {
            if (txt.getSkin() instanceof BehaviorSkinBase)
                ((BehaviorSkinBase) txt.getSkin()).getBehavior().traverseNext();

        });
    }
}
    
09.05.2017 / 17:47