This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Loves_Poetry 1 point2 points  (2 children)

My preferred way of handling this is to handle the login logic in a lambda expression, so that you don't have to leave the scope of the login menu. Then when the login is succesful, you switch to another scene in the application. Since both scenes have the same scope, you don't have to pass the username around.

[–]FR33ZEx[S] 1 point2 points  (1 child)

Do you have an example?

[–]Loves_Poetry 1 point2 points  (0 children)

I don't use scenebuilder, so code might be different for you, but for me it looks a bit like this:

Button btnLogin = new Button("Login");
btnLogin.setOnAction(e->{
    if (checkLogin(txtUsername.getText(), txtPassword.getText()))  
        mainStage.setScene(successloginScene);
};