JavaFX 到常规 Java 类参数问题

发布于 2024-09-06 03:27:29 字数 530 浏览 2 评论 0原文

我的目标是创建一个使用 javafx 表单(由单独的 java 类处理)的小型 javafx 应用程序,例如:Login.fx (GUI) 调用 LoginFunc.java 中的方法。处理用户交互。

我的问题是我需要将用户输入的用户名和密码传递给 LoginFunc。 通常在 swing 应用程序中,我使用构造函数,例如

public LoginFunc (String username, String password) { ?

我如何从 javafx 文件调用这样的类 我当前的代码是:

function btnLoginAction(): Void { var 用户名:字符串; var 密码:字符串; var login: LoginFunc;

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

}

感谢任何帮助!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咋地 2024-09-13 03:27:29

如果我正确理解你的问题,我想你想将其添加到 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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文