bonjour a tous
voilà , j'ai un petit probleme qui demande votre experience du java.
je fais un projet a rendre pour le 19 decembre et j'ai une exception in thread comme ceci :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Listener.actionPerformed(Listener.java:38)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)On crée l'adherent : 0

at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)



ca fait un bout de temps que je cherche , mais je ne trouve pas d'ou ca vient..... j'ai un peu honte.

je vous montre un peu 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
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.JComboBox;
import javax.swing.JTextField;
 
 
public class Listener implements ActionListener{
	Client [] monClient;
 
	JTextField field2;	JTextField field3;
	JTextField field4;	JTextField field5;	JTextField field6;
	JTextField field7;	JTextField field8;JTextField field9;	JTextField field10;
 
	JComboBox b;
 
	public Listener (Client [] _c,JTextField _2,JTextField _3,
	JTextField _4,JTextField _5,JTextField _6,JTextField _7,JTextField _8 ,JComboBox _b,JTextField _9){
 
		this.field2 = _2;
		this.field3 = _3;
		this.field4 = _4;
		this.field5 = _5;
		this.field6 = _6;
		this.field7 = _7;
		this.field8 = _8;
		this.field9 = _9;
 
		this.monClient = _c;
		this.b = _b;
 
	}
 
	public void actionPerformed(ActionEvent arg0) {
		System.out.println ("Creation");
		int i = Client.nombreTotal;
		System.out.println ("On crée l'adherent : "+i);
		this.monClient[i] = new Client(i,field2.getText() , field3.getText(), field4.getText(),field5.getText(),field6.getText(),field7.getText(),field8.getText(),b.getSelectedItem(),field9.getText());
	}
}

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
import javax.swing.*;          
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
 
public class maJFrame implements ActionListener {
//JLabels et JButton pour la modification/creation du client--------------------------------------------------------------------
	JLabel label1;		
	JLabel label2;		
	JLabel label3;
	JLabel label4;		
	JLabel label5;		
	JLabel label6;
	JLabel label7;		
	JLabel label8;		
	JLabel label9;
	JLabel label10;	    
	JLabel label11;
 
	JLabel text1;		
	JLabel text2;		
	JLabel text3;
 
	JTextField field1;	JTextField field2;	JTextField field3;
	JTextField field4;	JTextField field5;	JTextField field6;
	JTextField field7;	JTextField field8;	JTextField field9;
	JTextField field10;	JTextField field11;
 
	JButton button1;		
	JButton button2;
	JComboBox box;
//FIN--------------------------------------------------------------------------------------------------------------------------
//JLabels et JButton pour la creation d'une commande---------------------------------------------------------------------------
 
	JLabel label12;
 
	JLabel text4;	JLabel text5;	JLabel text6;
	JLabel text7;	JLabel text8;	JLabel text9;
	JLabel text10;	JLabel text11;	JLabel text12;
	JLabel text13;
 
	JTextField field12;	JTextField field13;	JTextField field14;
	JTextField field15;	JTextField field16;	JTextField field17;
	JTextField field18;	JTextField field19;
 
	 JButton button3;		JButton button4;
//FIN--------------------------------------------------------------------------------------------------------------------------
	public Component createComponents() {
		Client [] c = new Client[50];
		JPanel pane = new JPanel(new GridLayout(19, 2));
		JPanel pane2 = new JPanel (new GridLayout(11,2));
		JTabbedPane tabpane = new JTabbedPane();
		pane.setBorder(BorderFactory.createEmptyBorder(
                10, //top
                10, //left
                10, //bottom
                10) //right
                );
		pane2.setBorder(BorderFactory.createEmptyBorder(
				10, //top
				10, //left
				10, //bottom
				10) //right
				);
 
/******************************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////PANE//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
******************************************************************************************************************************/
		 text1   = new JLabel ("Créer/Modifier un client");
 
		 button1 = new JButton ("Valider");
		 button2 = new JButton ("Retour");
 
		 label1  = new JLabel ("N° client");		
		 label2  = new JLabel ("Nom");			field2  = new JTextField ();
	   	 label3  = new JLabel ("Prénom");		field3  = new JTextField ();
	     label4  = new JLabel ("Nom Société");	field4  = new JTextField ();
		 label5  = new JLabel ("N° CNE");		field5  = new JTextField ();
	     label6  = new JLabel ("Téléphone");	field6  = new JTextField ();
		 label7  = new JLabel ("Adresse");		field7  = new JTextField ();
	   	 label8  = new JLabel ("Précision");	field8  = new JTextField ();
	     //label9  = new JLabel ("Code Postal");	field9  = new JTextField ();
		 label10 = new JLabel ("Ville");		//field10 = new JTextField ();
		 label11 = new JLabel ("Observation");	field11 = new JTextField ();
		 box = new JComboBox();
		 box.addItem("Versailles");
		 box.addItem("Le Chesnay");
		 box.addItem("Rocquencourt");
		 box.addItem("La Celle St Cloud");
 
	        //On l'ajoute au container
			pane.add(new JLabel(""));
			pane.add(text1);
			pane.add(new JLabel(""));
 
			pane.add(new JLabel(""));
			pane.add(new JLabel(""));
			pane.add(new JLabel(""));
 
			pane.add(label1);
			pane.add(new JLabel("auto")); // récuperer code client dans Commande.java ou generer 
			pane.add(new JLabel(""));
 
			pane.add(label2);
			pane.add(field2);
			pane.add(new JLabel(""));
 
			pane.add(label3);
			pane.add(field3);
			pane.add(new JLabel(""));
 
			pane.add(label4);
			pane.add(field4);
			pane.add(new JLabel(""));
 
			pane.add(label5);
			pane.add(field5);
			pane.add(new JLabel(""));
 
			pane.add(label6);
			pane.add(field6);
			pane.add(new JLabel(""));
 
			pane.add(label7);
			pane.add(field7);
			pane.add(new JLabel(""));
 
			pane.add(label8);
			pane.add(field8);
			pane.add(new JLabel(""));
 
			//pane.add(label9);
			//pane.add(field9);
			//pane.add(new JLabel(""));
 
			pane.add(label10);
			//pane.add(field10);
			pane.add(box);
			pane.add(new JLabel(""));
 
			pane.add(label11);
			pane.add(field11);
			pane.add(new JLabel(""));
 
			pane.add(new JLabel(""));
			pane.add(button1);
			pane.add(new JLabel(""));
/******************************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////PANE2/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
******************************************************************************************************************************/
			 //text4   = new JLabel ("date");
			 //text5   = new JLabel ("heure");
			 text6   = new JLabel ("N° Commande");
			 text7   = new JLabel ("Standardiste");
			 text9   = new JLabel ("Téléphone");
			 text8   = new JLabel ("Nom");
			 text10   = new JLabel ("Code produit");
			 text11   = new JLabel ("Ingrédient(s)");
			 text12   = new JLabel ("Quantité");
			 text13  = new JLabel ("Prix");
 
			 label12  = new JLabel ("service");			 
 
			 field12  = new JTextField ();
			 field13  = new JTextField ();
			 field14  = new JTextField ();
			 field15  = new JTextField ();
			 field16  = new JTextField ();
			 field17  = new JTextField ();
			 field18  = new JTextField ();
			 field19  = new JTextField ();
 
		     button3 = new JButton ("Créer/Modifier");
		     button4 = new JButton ("Ajouter");
 
		     Date rightNow = new Date();
		     // Premier format de la date
		     SimpleDateFormat myFormat = new SimpleDateFormat("dd MMM yyyy");
		     // Second format de l'heure
		     SimpleDateFormat myFormat2 = new SimpleDateFormat("HH:mm:ss");
 
		     text4 = new JLabel (""+
		    		 // Applique le format myFormat sur l'objet rightNow passé en argument de la methode format()
		    		 myFormat.format(rightNow)
		    		 );
 
		     text5 = new JLabel (""+
		    		 myFormat2.format(rightNow)
		    		 );
		        //On l'ajoute au container
				pane2.add(text4);
				pane2.add(text5);
				pane2.add(label12);
 
				pane2.add(text6);
				pane2.add(new JLabel ("auto"));
				pane2.add(new JLabel(""));
 
				pane2.add(text7);
				pane2.add(field13);
				pane2.add(new JLabel(""));
 
				pane2.add(new JLabel(""));
				pane2.add(new JLabel(""));
				pane2.add(new JLabel(""));
 
				pane2.add(text8);
				pane2.add(field14);
				pane2.add(new JLabel(""));
 
				pane2.add(text9);
				pane2.add(field15);
				pane2.add(button3);
 
				pane2.add(new JLabel(""));
				pane2.add(new JLabel(""));
				pane2.add(new JLabel(""));
 
				pane2.add(text10);
				pane2.add(field16);
				pane2.add(new JLabel(""));
 
				pane2.add(text11);
				pane2.add(field17);
				pane2.add(new JLabel(""));
 
				pane2.add(text12);
				pane2.add(field18);
				pane2.add(new JLabel(""));
 
				pane2.add(text13);
				pane2.add(field19);
				pane2.add(button4);
 
				Listener t = new Listener (c, field2, field3, field4,field5,field6,field7,field8,box,field9 );
				button1.addActionListener (t);
 
				//on les rajoutes aux tabpane
				tabpane.addTab("creer/modifier client", null, pane, "pour creer ou modifier un client");
		        tabpane.addTab("Creer Commande", null, pane2, "pour ajouter une commande");
		        return tabpane;
	}
 
 
	public void actionPerformed(ActionEvent e) {
    }
	private static void createAndShowGUI() {
        JFrame frame = new JFrame("Standartiste , à vous !");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
        maJFrame app = new maJFrame();
        Component contents = app.createComponents();
        frame.getContentPane().add(contents, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
    }
 
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
 
}


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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
public class Client {
 
int Num_client;	
String Nom;	
String Prénom;
String Société;
String CNE;		
String Téléphone;	
String Adresse;		
String Précision;	
int Code_postal;	
Object Ville;		
String Observation;
public static int nombreTotal=0;
 
 
public Client (int _nc,String _nom,String _prenom,String _soc,String _cne,String _tel,String _adr,String _pre,
Object _vil,String _obs){
	this.Num_client = _nc;
	this.Nom = _nom;
	this.Prénom = _prenom;
	this.Société = _soc;
	this.CNE = _cne;
	this.Téléphone = _tel;
	this.Adresse = _adr;
	this.Précision = _pre;
	this.Ville = _vil;
	this.Observation = _obs;
 
	if (this.Ville == "Versailles"){
		this.Code_postal = 78000;
	}else if (this.Ville == "Le Chesnay" || this.Ville == "Rocquencourt"){
		this.Code_postal = 78150;
	}else if(this.Ville == "La Celle St Cloud"){
		this.Code_postal = 78170;
	}
 
	Client.nombreTotal++;
}
 
public Client (String _nom,String _prenom,String _soc,String _cne,String _tel,String _adr,String _pre,Object _vil,
		String _obs , int _nu){
			this.Nom = _nom;
			this.Prénom = _prenom;
			this.Société = _soc;
			this.CNE = _cne;
			this.Téléphone = _tel;
			this.Adresse = _adr;
			this.Précision = _pre;
			this.Ville = _vil;
			this.Observation = _obs;
			this.Num_client = Client.nombreTotal;
 
			if (this.Ville == "Versailles"){
				this.Code_postal = 78000;
			}else if (this.Ville == "Le Chesnay" || this.Ville == "Rocquencourt"){
				this.Code_postal = 78150;
			}else if(this.Ville == "La Celle St Cloud"){
				this.Code_postal = 78170;
			}
 
			Client.nombreTotal++;
}
}


Je vous remercie d'avance si vous reussissez a trouver l'erreur et même si vous la trouvez pas .
moi je vois vraiment pas là !