我有这段代码,当我在//error注释处加上&&时,它会出现void类型不允许的错误。当我删除&&时,就不会出现此错误。
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);
}
}
希望有人能够帮助我!谢谢