文本域比较错误
Textfeild Comparing errors
我正在尝试检查一个字符串是否等于默认值或什么都没有,但它一直在我的检查中漏掉。有任何想法吗?
检查:
if( lblEnterServerIp.getText() == null|| lblEnterServerIp.getText().isEmpty() || lblEnterServerIp.getText().equals("000.000.000.000")) {
popUp("No IP address entered");
return;
}else {
ip = lblEnterServerIp.getText().split("\:")[0];
}
设置文本域:
ipField = new JTextField();
ipField.setBounds(124, 201, 86, 20);
ipField.setText("000.000.000.000");
panel_1.add(ipField);
ipField.setColumns(10);
"The field is named ipField but you check lblEnterServerIp. According to the name, you are performing checks on a label instead of the text field"
BackSlash 在答案的评论中提供的答案。
我正在尝试检查一个字符串是否等于默认值或什么都没有,但它一直在我的检查中漏掉。有任何想法吗? 检查:
if( lblEnterServerIp.getText() == null|| lblEnterServerIp.getText().isEmpty() || lblEnterServerIp.getText().equals("000.000.000.000")) {
popUp("No IP address entered");
return;
}else {
ip = lblEnterServerIp.getText().split("\:")[0];
}
设置文本域:
ipField = new JTextField();
ipField.setBounds(124, 201, 86, 20);
ipField.setText("000.000.000.000");
panel_1.add(ipField);
ipField.setColumns(10);
"The field is named ipField but you check lblEnterServerIp. According to the name, you are performing checks on a label instead of the text field" BackSlash 在答案的评论中提供的答案。