Попробуйте использовать yourNextTextField.requestFocus()
в yourCurrentTextField.setOnAction()
.
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
*
* @author blj0011
*/
public class JavaFXApplication200 extends Application
{
@Override
public void start(Stage primaryStage)
{
TextField textField1 = new TextField();
TextField textField2 = new TextField();
TextField textField3 = new TextField();
textField1.setOnAction((event) -> {
//Do some stuff
textField2.requestFocus();
});
textField2.setOnAction((event) -> {
//Do some stuff
textField3.requestFocus();
});
textField3.setOnAction((event) -> {
//Do some stuff
textField1.requestFocus();
});
Parent root = new VBox(textField1, textField2, textField3);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
launch(args);
}
}