0
votes

My aim is to create a small javafx application that makes use of javafx forms (handled by separate java classes) for example: Login.fx (GUI) calls methods from LoginFunc.java. to handle user interactions.

My problem is that I need to pass the username and password entered by the user to LoginFunc. Usually in swing applications i use a constructor such as

public LoginFunc (String username, String password) { }

How can I call such a class from a javafx file? my current code is:

function btnLoginAction(): Void { var username: String; var password: String; var login: LoginFunc;

    username = txtUsername.text;
    password = txtPassword.text;

}

Any help is appreciated!

1

1 Answers

0
votes

If I understand your question correctly, I think you want to add this to Login.fx:

def loginButton = Button {
    action: btnLoginAction
}
function btnLoginAction(MouseEvent:e):Void {
    var username = txtUsername.text;
    var password = txtPassword.text;
    // construct new LoginFunc note the CURLY braces
    var login:LoginFunc = LoginFunc{};
    login.doSomething(username, password);
}

If I misinterpreted, please let me know.