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?
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?
You can do this:
textfield1.setOnKeyPressed( (keyEvent) -> {
if(keyEvent.getCode() == KeyCode.ENTER)
textfield2.requestFocus();
} );
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();
});
}
}