salut à tous
je veux faire un teste sur le format du contenu de JTexteField mais ça marche pas.
voici le code:


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
17
18
19
20
21
22
23
24
25
26
27
public void jTextField4_focusLost(FocusEvent e)
    {         if (jTextField4.getText().length() > 10)
          { JOptionPane.showMessageDialog(null,"vous devez entrer une date de format jj/mm/aaaa");
         }
 
         String[] tab = new String[10];
         for(int i=0;i<10;i++)
         {
           tab[i] = jTextField1.getText();
         }
         int j1 = Integer.parseInt(tab[0]);
         int j2 = Integer.parseInt(tab[1]);
         int m1 = Integer.parseInt(tab[3]);
         int m2 = Integer.parseInt(tab[4]);
         int a1 = Integer.parseInt(tab[6]);
         int a2 = Integer.parseInt(tab[7]);
         int a3 = Integer.parseInt(tab[8]);
         int a4 = Integer.parseInt(tab[9]);
         int jj = (j1 * 10) + j2;
         int mm = (m1 * 10) + m2;
         int aaaa = (a1 * 1000) + (a2 * 100) + (a3 * 10) + a4;
         if (( (jj <= 0) || (jj > 31)) && ( (mm <= 0) || (mm > 12)) &&  (aaaa < 0))
         {
        JOptionPane.showMessageDialog(null,"Le format de la date est incorrect");
         }}
 
}