[英]Handle Logout Button Action of JavaFX Application
Here is part of my code that shows error. 这是显示错误的代码的一部分。 This is done inside public void start
method. 这是在public void start
方法内部完成的。 I have already done the Login part, whenever user logs in the id and password remains in the TextField. 每当用户登录ID和密码保留在TextField中时,我已经完成了Login部分。 Which is why I have created a logout button so that when user clicks on it, I want the useridtextfield
& passwordtextfield
to be empty. 这就是为什么我创建了一个注销按钮,以便当用户单击它时,我希望useridtextfield
和passwordtextfield
为空。
LogoutButton.setOnAction(e->
UserIdTextField==null;
PasswordTextField==null;);
I have searched over the internet about this problem but got no solution regarding JavaFX Logout handling. 我已经在互联网上搜索了有关此问题的信息,但没有有关JavaFX注销处理的解决方案。 I have no idea about FXML so I would appreciate any help. 我不了解FXML,所以我将不胜感激。
The syntax for a lambda expression with multiple statements is 具有多个语句的lambda表达式的语法为
logoutButton.setOnAction(e -> {
/* statements */
});
(Ie you need to delimit the statements with {
... }
.) (即,您需要使用{
... }
分隔语句。)
As pointed out in the comments, comparing the text fields to null is probably not what you want to do here, but it will at least compile. 正如评论中指出的那样,将文本字段与null进行比较可能不是您要在此处执行的操作,但至少可以进行编译。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.