【发布时间】:2021-08-10 23:43:43
【问题描述】:
我有一个小问题,我无法解决。 我想让我的代码检查电子邮件和密码是否匹配,然后 然后 关闭窗口。这个动作:
btnLogin.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean status = Email_Verification.email_validation(email_text.getText().toString().trim());
if (status) {
lbl_inco_email.setText(null);
} else {
lbl_inco_email.setText("Please enter a valid email");
}
boolean stat = Password_Verification.password_validation(password_Field.getPassword().toString());
if (stat) {
lbl_inco_pwd.setText(null);
} else {
lbl_inco_pwd.setText("Please enter a valid Password");
}
/* Exit and redirect to the main application if the email/pwd matches the database */
/** MAIN__WINDOW __EXIT__ONCLICK__ = new MAIN__WINDOW();
__EXIT__ONCLICK__.setVisible(true); */
}
});
【问题讨论】:
-
也许试试
InputVerifier,检查here? -
@trashgod 你能否检查一个基于this comment 的问题,其中提到框架图标在 Mac 上不起作用? AFAIR 您提供的屏幕截图表明 Mac 不使用自定义框架图标。 (不过,我可能记错了细节。)
-
OP: 1) 为了尽快获得更好的帮助,edit 添加minimal reproducible example 或Short, Self Contained, Correct Example。 2) 请学习常见的 Java 命名法(命名约定 - 例如
EachWordUpperCaseClass、firstWordLowerCaseMethod()、firstWordLowerCaseAttribute,除非它是UPPER_CASE_CONSTANT)并始终如一地使用它。请特别注意,_字符是通用命名法一部分的唯一情况是常量。