如果我没有在文本字段中输入任何字符串值,则应该显示错误消息,但是这里的情况恰好相反。我的意思是正在显示运行消息。我可以在这里知道我的代码有什么问题吗?
private void searchButton1ActionPerformed(java.awt.event.ActionEvent evt){
String dishName = dishSearch.getText();
int count = 0;
String addName = " ";
if ("".equals(dishName)) {
JOptionPane.showMessageDialog(this, "Error");
} else {
for (int i = 0; i < menuTable1.getRowCount(); i++) {
if (menuTable1.getValueAt(i, 1) == dishName) {
count += 1;
addName += menuTable1.getValueAt(i, 2) + ", ";
}
}
JOptionPane.showMessageDialog(this, "There are " + count + " " + dishName + " dishes " + addName);
}
}