1
我正在为我制作的游戏写一个登录脚本。我目前正在检查提供的信息以确保其有效。我遇到了这个问题,当我去检查2个文本字段是否具有相同的值时。当他们这样做时,他们做的和我想要的相反。很奇怪的摇摆错误
private void regAccConfEmailFieldFocusFocusLost(FocusEvent event) {
if(regAccConfEmailField.getText() == regAccEmail.getText() && regAccConfEmail != null)
{
regAccConfEmailField.setBorder(new LineBorder(Color.green, 1, false));
confEmail = true;
}
else
{
regAccConfEmailField.setBorder(new LineBorder(Color.red, 1, false));
confEmail = false;
}
}
private void regAccConfSecQFieldFocusFocusLost(FocusEvent event) {
if(regAccConfSecQField.getText() == null)
{
regAccConfSecQField.setBorder(new LineBorder(Color.red, 1, false));
secQuestion = false;
}
else
{
regAccConfSecQField.setBorder(new LineBorder(Color.green, 1, false));
secQuestion = true;
}
}
这是我的代码,我需要知道为什么每一种方法做什么它被赋予相反。
说,regAccConfEmailField和regAccEmailField都等于[email protected] 它会去if语句,而不是其他。如果需要,我可以提供更多的代码。
好吧,我对这个还是有点新的。我目前是我高中的二年级学生。非常感谢! – Synposis
不客气! :) – Reimeus
尽管这有帮助,但它并没有解决我的问题D = – Synposis