我有这段代码,它说这里不允许使用 void 类型(我放 //error 注释的地方)当我删除 && ..... 它不会给出错误
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == ok) {
Contact nweC = null;
String vnm = tfVoor.getText();
String anm = tfAchter.getText();
String em = tfEmail.getText();
if (em.trim().length() > 0 && !hetBoek.heeftContact(em)) {
nweC = new Contact(vnm, anm, em);
} else {
tfEmail.setText("");
JOptionPane.showMessageDialog(null, "Onjuist emailadres", "Mislukt", JOptionPane.PLAIN_MESSAGE);
}
//error if (nweC != null && hetBoek.voegContactToe(nweC)) {
JOptionPane.showMessageDialog(null, "Toevoegen gelukt", "Succes", JOptionPane.PLAIN_MESSAGE);
}
} else if (ae.getSource() == cancel) {
tfVoor.setText("");
tfAchter.setText("");
tfEmail.setText("");
} else if (ae.getSource() == toon) {
String s = hetBoek.toString();
JOptionPane.showMessageDialog(null, s, "Druk op OK",
JOptionPane.PLAIN_MESSAGE);
}
}
我希望有一个人可以帮助我!谢谢