Bonsoir,

Lorsque j'exécute ma classe , il y a trois boite de dialogues qui s'affichent avant même que la fenêtre n'apparaisse ( il faut que je clique sur ok pour qu'elle s'affiche)





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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
 
public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Liste_des_clients frame = new Liste_des_clients();
					frame.setVisible(true);
 
				} catch (Exception e) {
					e.printStackTrace();
				}
 
 
 
 
 
			} 
		});
	}
 
	/**
         * Create the frame.
         */
	public Liste_des_clients() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1231, 780);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
 
		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(new Color(0, 0, 0)));
		contentPane.add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		panel.setBackground(new Color(255,255,255));
 
		JButton btnRechercher = new JButton("Rechercher");
		btnRechercher.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnRechercher.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Connection connection;
			PreparedStatement statement ;
			      connection = null;
 
 
 
 
 
			      try
			      {
			    	 try {
						Class.forName("org.sqlite.JDBC");//VK_undefined
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block 
						e.printStackTrace();
					}
			  connection = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\tosiba\\eclipse-workspace\\training1\\src\\BDD.db");
 
			  statement = connection.prepareStatement("SELECT * FROM Client WHERE Nom= ? AND Prenom= ? ");
			  //statement.setString(1, textField.getText());
			  //statement.setString(2,textField_1.getText());
 
			  statement.setString(1, comboBox_1.getSelectedItem().toString());
			  statement.setString(2, comboBox_2.getSelectedItem().toString());
 
			  ResultSet rs = statement.executeQuery();
 
 
 
 
			  table.setModel(DbUtils.resultSetToTableModel(rs));
				 statement.close();
				 connection.close();
 
 
				 }
 
 
 
 
		catch(SQLException e1)
		{
 
		  System.err.println(e1.getMessage());
		  JOptionPane.showMessageDialog(null, "Ce nom n'existe pas");
 
		} 
 
			};
		});
 
 
 
 
 
 
 
		btnRechercher.setBounds(383, 177, 132, 42);
		panel.add(btnRechercher);
		btnRechercher.setBackground(new Color(235,162,56));
 
		textField = new JTextField();
		textField.setFont(new Font("Tahoma", Font.PLAIN, 15));
		textField.setBounds(305, 60, 157, 23);
		panel.add(textField);
		textField.setColumns(10);
 
 
		textField_1 = new JTextField();
		textField_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
		textField_1.setColumns(10);
		textField_1.setBounds(305, 92, 157, 23);
		panel.add(textField_1);
 
		JLabel lblPrnom = new JLabel("Pr\u00E9nom :");
		lblPrnom.setForeground(new Color(25, 25, 112));
		lblPrnom.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblPrnom.setBounds(31, 187, 69, 23);
		panel.add(lblPrnom);
 
		JLabel lblNom = new JLabel("Nom :");
		lblNom.setForeground(new Color(25, 25, 112));
		lblNom.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblNom.setBounds(31, 143, 69, 23);
		panel.add(lblNom);
 
		scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 492, 1124, 192);
		panel.add(scrollPane);
 
		table_1 = new JTable();
		scrollPane.setViewportView(table_1);
 
		btnListeDesClients = new JButton("Afficher ");
		btnListeDesClients.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnListeDesClients.setBackground(new Color(235,162,56));
 
		btnListeDesClients.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Connection  connection= null;
				java.sql.Statement statement;
 
				try {
					try {
						Class.forName("org.sqlite.JDBC");
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					connection = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\tosiba\\eclipse-workspace\\training1\\src\\BDD.db");
					statement= connection.createStatement();
					ResultSet rs= statement.executeQuery("SELECT * FROM Client ");
 
					table_1.setModel(DbUtils.resultSetToTableModel(rs));
					//JOptionPane.showMessageDialog(null, " ");
					statement.close();
				    connection.close();
 
 
						//dispose();
 
				} catch (Exception e) {
					e.printStackTrace();
					JOptionPane.showMessageDialog(null, "erreur");
				}
			}
		});
 
 
		btnListeDesClients.setBounds(222, 402, 147, 34);
		panel.add(btnListeDesClients);
 
		lblNewLabel = new JLabel("Liste des clients :");
		lblNewLabel.setForeground(new Color(25, 25, 112));
		lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
		lblNewLabel.setBounds(10, 352, 189, 34);
		panel.add(lblNewLabel);
 
		scrollPane_1 = new JScrollPane();
		scrollPane_1.setBounds(10, 243, 1124, 88);
		panel.add(scrollPane_1);
 
		table = new JTable();
		scrollPane_1.setViewportView(table);
 
		JLabel lblRechercherUnClient = new JLabel("Rechercher un client:");
		lblRechercherUnClient.setForeground(new Color(25, 25, 112));
		lblRechercherUnClient.setFont(new Font("Tahoma", Font.BOLD, 16));
		lblRechercherUnClient.setBounds(31, 98, 184, 34);
		panel.add(lblRechercherUnClient);
 
		JButton btnSupprimer = new JButton("Suspendre");
		btnSupprimer.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
 
				Connection  connection= null;
				java.sql.Statement statement;
 
				try {
					try {
						Class.forName("org.sqlite.JDBC");
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					connection = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\tosiba\\eclipse-workspace\\training1\\src\\BDD.db");
					//JOptionPane.showMessageDialog(null , "connexion effective");
					statement= connection.createStatement();
 
					 statement.executeUpdate("UPDATE Client SET Etat= 'Suspendu' WHERE Nom='" +  textField.getText()  +"' AND Prenom='"  +textField_1.getText() +"'");
					  ResultSet rs=statement.executeQuery("Select Nom FROM Projet ");
					 comboBox.addItem(rs.getString("Nom"));
 
					JOptionPane.showMessageDialog(null, " Voulez vraiment Supendre ... ");
					statement.close();
				    connection.close();
 
 
						//dispose();
 
				} catch (Exception e) {
					e.printStackTrace();
					JOptionPane.showMessageDialog(null, "erreur");
				}
 
 
 
 
			}
		});
		btnSupprimer.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnSupprimer.setBounds(597, 177, 132, 42);
		btnSupprimer.setBackground(new Color(235,162,56));
		panel.add(btnSupprimer);
 
		btnNewButton = new JButton("Nouveau client ");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				AJOUTER a =new AJOUTER ();
				a.setVisible(true);
			}
		});
		btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnNewButton.setBounds(284, 0, 157, 34);
		panel.add(btnNewButton);
		btnNewButton.setBackground(new Color(199, 21, 133));
 
		btnProjet = new JButton("Projet ");
		btnProjet.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Projet p = new Projet();
			}
		});
		btnProjet.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnProjet.setBounds(436, 0, 165, 34);
		btnProjet.setBackground(new Color(255, 239, 213));
		panel.add(btnProjet);
 
 
		btnAfficherParClient = new JButton("Affichage par projet");
		btnAfficherParClient.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
 
				Connection  connection= null;
				PreparedStatement statement;
 
				try {
					try {
						Class.forName("org.sqlite.JDBC");
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					connection = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\tosiba\\eclipse-workspace\\training1\\src\\BDD.db");
					statement= connection.prepareStatement("SELECT * FROM Client WHERE Nom_du_projet= ?");
					statement.setString(1, comboBox.getSelectedItem().toString());
					ResultSet rs= statement.executeQuery();
 
					table_1.setModel(DbUtils.resultSetToTableModel(rs));
					//JOptionPane.showMessageDialog(null, " ");
					statement.close();
				    connection.close();
 
 
						//dispose();
 
				} catch (Exception e) {
					e.printStackTrace();
					JOptionPane.showMessageDialog(null, "erreur");
				}
 
			}
		});
		btnAfficherParClient.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnAfficherParClient.setBounds(220, 447, 173, 34);
		btnAfficherParClient.setBackground(new Color(235,162,56));
 
		panel.add(btnAfficherParClient);
		comboBox.setForeground(new Color(25, 25, 112));
 
 
		comboBox.setBounds(51, 449, 137, 20);
		panel.add(comboBox);
 
 
 
		combo c = new combo();
 
		c.fillListeCombo(comboBox, comboBox_1, comboBox_2);
 
		JButton btnNewButton_1 = new JButton("Acceuil");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Acceuil a = new Acceuil();
				a.setVisible(true);
			}
		});
		btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnNewButton_1.setBounds(139, 0, 147, 34);
		panel.add(btnNewButton_1);
		btnNewButton_1.setBackground(new Color(255, 228, 225));
 
		btnNewButton_2 = new JButton("Versement");
		btnNewButton_2.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Versement_Total v= new Versement_Total();
				v.setVisible(true);
			}
		});
		btnNewButton_2.setBounds(600, 0, 157, 34);
		panel.add(btnNewButton_2);
		btnNewButton_2.setBackground(new Color(255, 255, 102));
 
		btnNewButton_3 = new JButton("Rechercher");
		btnNewButton_3.setForeground(new Color(255, 255, 255));
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Clientparprojet c = new Clientparprojet();
				c.setVisible(true);
			}
		});
		btnNewButton_3.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnNewButton_3.setBounds(757, 0, 147, 34);
		btnNewButton_3.setBackground(new Color(25, 25, 112));
		panel.add(btnNewButton_3);
 
		comboBox.setBackground(new Color(255,255,255));
 
 
		table t = new table();
		t.Liste(table_1);
		comboBox_1.setModel(new DefaultComboBoxModel(new String[] {""}));
 
		comboBox_1.setForeground(new Color(25, 25, 112));
 
 
		comboBox_1.setBounds(113, 146, 129, 20);
		comboBox_1.setBackground(new Color (255,255,255));
		panel.add(comboBox_1);
		comboBox_2.setModel(new DefaultComboBoxModel(new String[] {""}));
 
 
		comboBox_2.setBounds(113, 190, 129, 20);
		comboBox_2.setBackground(new Color (255,255,255));
		panel.add(comboBox_2);
 
 
		  try {
				try {
					Class.forName("org.sqlite.JDBC");
				} catch (ClassNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
 
 
				Connection	connection1=null;
				PreparedStatement statement1=null;
 
				connection1 = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\tosiba\\eclipse-workspace\\training1\\src\\BDD.db");
				String sql= "SELECT Nom FROM Client";
				statement1 = connection1.prepareStatement(sql);
 
				ResultSet rs= statement1.executeQuery();
 
				while(rs.next()) {
					 comboBox_1.addItem(rs.getString("Nom"));
 
				}
 
				String   sql1="SELECT Prenom FROM Client ";
 
				statement1= connection1.prepareStatement(sql1);
 
				//statement1.setString(1,comboBox_1.getSelectedItem().toString() );
 
				ResultSet rs1= statement1.executeQuery();
				while(rs1.next()) {
				comboBox_2.addItem(rs1.getString("Prenom"));
 
				} 
 
 
				JOptionPane.showMessageDialog(null, " ");
				statement1.close();
			    connection1.close();
 
 
					//dispose();
 
			} catch (Exception e) {
				e.printStackTrace();
				JOptionPane.showMessageDialog(null, "erreur");
			}
 
	}
}