java错误日志寄存器中的验证

java错误日志寄存器中的验证,java,validation,user-interface,login,passwords,Java,Validation,User Interface,Login,Passwords,我正在尝试设置确认密码的验证,所有文本字段中都必须有值。我只是一个初学者,先生,我正在练习建立一个登录和注册程序 对不起,我的英语说得不是很好 我的问题是我的代码运行不正常。它一直在说“填满空间” 试试这个代码。您应该使用等于()而不是==来进行字符串比较找不到符号:(我不知道equals的用法,抱歉。我犯了一个拼写错误。请使用等于(),:) String username = usernamefield.getText(); String password = passwordfield.ge

我正在尝试设置确认密码的验证,所有文本字段中都必须有值。我只是一个初学者,先生,我正在练习建立一个登录和注册程序

对不起,我的英语说得不是很好

我的问题是我的代码运行不正常。它一直在说“填满空间”


试试这个代码。您应该使用等于()而不是==来进行字符串比较

找不到符号:(我不知道equals的用法,抱歉。我犯了一个拼写错误。请使用等于(),:)
String username = usernamefield.getText();
String password = passwordfield.getText();
String cpassword = cpasswordfield.getText();
if ((username != null) || (password != null) || (cpassword != null)) {
    if (password == cpassword) {
        db.insertData(username, password);
        JOptionPane.showMessageDialog(null, "data has been entered");
    }
    else {
        JOptionPane.showMessageDialog(null, "Please Fill the spaces");
    }
}
else if (password != cpassword) {
    JOptionPane.showMessageDialog(null, "Password Mismatch");
}
if((username != null) || (password != null) || (cpassword != null) ){
if(password.equals(cpassword)){
    db.insertData(username, password);
    JOptionPane.showMessageDialog(null, "data has been entered");
}else {
    JOptionPane.showMessageDialog(null, "Password Mismatch");
}


 } else {
JOptionPane.showMessageDialog(null, "Please Fill the spaces");
}