Comme il est noté j'ai utilisé une méthode que je trouve un peu "spéciale" pour lire des ligne à partir d'un JTextArea ,la voici:
Malheureusement on m'afiiche une exception "java.lang.NullPointerException", qui parvient de la ligne de substring.
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
28
29
30
31
32
33 public static String[] remplirTableau(FenêtrePrincipale frame){ String[] tab=null; JTextArea text=frame.getjTextArea(); int comptLigne =text.getLineCount(); //System.out.println(comptLigne); for(int i=0;i<comptLigne;i++){ int debut=0; try { debut=text.getLineStartOffset(i); System.out.println(debut); } catch (BadLocationException e) { // TODO Auto-generated catch block e.printStackTrace(); } int fin=0; try { fin = text.getLineEndOffset(i); System.out.println(fin); } catch (BadLocationException e) { // TODO Auto-generated catch block e.printStackTrace(); } tab[i]=text.getText().substring(0, 2); System.out.println(tab[i]); } return tab; }
Où est le problème sachant que que j'ai testé les deux variables "debut" et "fin "et je m'ai assuré qu'ils prennent des bonnes valeurs?
Partager