bonjour ,
je cherche à supprimer une personne selon un nom , mais ça ne marche pas quand je met une condition sur le champs s'il est vide ou pas ( lignes en rouge), lorsque j'enlève les conditions ça marche :
méthode pour supprimer :
code du bouton supprimer :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 public static void supprimer(String n) { for(int i=0 ; i <lp.size() ; i++) { lp.remove(lp.get(i).getNom()); lp.remove(lp.get(i).getPrenom()); lp.remove(lp.get(i).getAdresse()); lp.remove(lp.get(i).getDateNaissance()); } }
merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 private void btnSuppActionPerformed(java.awt.event.ActionEvent evt) { JOptionPane j = new JOptionPane(); String n= jNom.getText(); if(n.equals("")){ j.showMessageDialog(null,"CHAMP VIDE","confirmation", JOptionPane.ERROR_MESSAGE); } else if(!n.isEmpty()) { int op= j.showConfirmDialog(null,"choisie une réponse","oui,Non",JOptionPane.YES_NO_OPTION , JOptionPane.QUESTION_MESSAGE); if (op == JOptionPane.OK_OPTION) { Stockage.supprimer(n); j.showMessageDialog(null,"personne "+n+" Supprimée","confirmation", JOptionPane.INFORMATION_MESSAGE); } } }
Partager