Bonjour à tous et toutes,

Voilà, j'ai un petit soucis lorsque je veux créer une fenêtre et l'afficher simplement...
L'erreur proviendrait de l'instruction setVisible(true) après la création de l'objet Fenetre, j'ai essayé de mettre l'instruction dans le constructeur pour voir si changements il y avait mais là également l'erreur se produit.
Le code du bouton d'appel et le code de la fenêtre :

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
	public JButton getJbAjouter(){
		if(jbAjouter==null){
			jbAjouter=new JButton("Ajouter");
			jbAjouter.addActionListener(new ActionListener(){
 
				public void actionPerformed(ActionEvent e) {
					// TODO Raccord de méthode auto-généré
					FenetreAjouterFormation f=new FenetreAjouterFormation(PaneListeFormation.this);
					//f.setVisible(true);
					PaneListeFormation.this.setEnabled(false);
				}
 
			});
		}
		return jbAjouter;
	}
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
package projet;
 
import javax.swing.*;
 
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
 
public class FenetreAjouterFormation extends JFrame{
 
		private JLabel jlHead=new JLabel("Créer une formation :");
		private JComboBox jcbCle1;
		private JComboBox jcbCle2;
		//private JSpinner jsCle3;
		private JLabel jlCle=new JLabel("Clé unique :");
		private JLabel jlCle1=new JLabel("Jour");
		private JLabel jlCle2=new JLabel("Type");
		//private JLabel jlCle3=new JLabel("Num");
 
		private JLabel jlProf= new JLabel("Professeur :");
		private JComboBox jcbProf;
 
		private JLabel jlLoca=new JLabel("Localisation : ");
		private JComboBox jcbLoca;
 
		private JLabel jlListe = new JLabel("Choisissez les étudiants concernés :");
		private JList jlEtudiant;
 
		private JButton jbAjouter;
		private JButton jbReini;
 
		private PaneListeFormation fle;
 
		public FenetreAjouterFormation(PaneListeFormation fle){
			this.fle=fle;
			this.setSize(550,380);
			this.setResizable(false);
			this.setTitle("Ajout d'une formation");
			this.setLocation(400,300);
			JPanel jp= new JPanel();
			GroupLayout gp= new GroupLayout(jp);
 
			jp.setLayout(gp);
 
			gp.setHorizontalGroup(
				gp.createSequentialGroup()
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlHead())
								.addComponent(this.getJlCle())
								.addComponent(this.getJlProf())
								.addComponent(this.getJlLoca())
								.addComponent(this.getJlListe())
								.addComponent(this.getJbReini())
					)
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlCle1())
								.addComponent(this.getJcbCle1())
								.addComponent(this.getJcbProf())
								.addComponent(this.getJcbLoca())
								.addComponent(this.getJlEtudiant())
					)
					.addGap(0)
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlCle2())
								.addComponent(this.getJcbCle2())
					)
/*					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlCle3())
								.addComponent(this.getJsCle3())
								.addComponent(this.getJbAjouter())  
					)  */
			);
			gp.setVerticalGroup(
				gp.createSequentialGroup()
					.addComponent(this.getJlHead())
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlCle1())
								.addGap(0)
								.addComponent(this.getJlCle2())
//								.addComponent(this.getJlCle3())
					)
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlCle())
								.addComponent(this.getJcbCle1())
								.addComponent(this.getJcbCle2())
//								.addComponent(this.getJsCle3())
					)
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlProf())
								.addComponent(this.getJcbProf())
					)
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlLoca())
								.addComponent(this.getJcbLoca())
					)
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJlListe())
								.addComponent(this.getJlEtudiant())
					)
					.addGroup(
							gp.createParallelGroup()
								.addComponent(this.getJbReini())
								.addComponent(this.getJbAjouter())
					)
			);
 
 
//			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			try {
				UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (UnsupportedLookAndFeelException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			this.add(jp,BorderLayout.WEST);
			this.setVisible(true);
			this.setDefaultCloseOperation(FenetreListeProfesseur.DISPOSE_ON_CLOSE);
		}
 
		public JLabel getJlHead() {
			return jlHead;
		}
 
		public JComboBox getJcbCle1() {
			if(jcbCle1==null){
				String[] jour = {"lun","mar","mer","jeu","ven","sam","dim"};
				jcbCle1=new JComboBox(jour);
				jcbCle1.setMaximumSize(new Dimension(60,30));
				jcbCle1.setMinimumSize(new Dimension(60,30));
				jcbCle1.setSelectedIndex(0);
			}
			return jcbCle1;
		}
 
		public JComboBox getJcbCle2() {
			if(jcbCle2==null){
				String[] type = {"parti","semi","group"};
				jcbCle2=new JComboBox(type);
				jcbCle2.setMaximumSize(new Dimension(70,30));
				jcbCle2.setMinimumSize(new Dimension(70,30));
				jcbCle2.setSelectedIndex(0);
			}
			return jcbCle2;
		}
 
		/*public JSpinner getJsCle3() {
			if(jsCle3==null){
				jsCle3=new JSpinner(new SpinnerNumberModel(1,1,100,1));
				jsCle3.setMaximumSize(new Dimension(50,30));
				jsCle3.setMinimumSize(new Dimension(50,30));
				jsCle3.setValue(1);
			}
			return jsCle3;
		}*/
 
		public JLabel getJlCle1() {
			return jlCle1;
		}
 
		public JLabel getJlCle2() {
			return jlCle2;
		}
 
		/*public JLabel getJlCle3() {
			return jlCle3;
		}*/
 
		public JLabel getJlProf() {
			return jlProf;
		}
 
		public JComboBox getJcbProf() {
			if(jcbProf==null){
				jcbProf=new JComboBox(getNomsProfs());
				jcbProf.setMaximumSize(new Dimension(160,30));
				jcbProf.setMinimumSize(new Dimension(160,30));
			}
			return jcbProf;
		}
		public String[] getNomsProfs(){
			String[] res = new String[this.fle.getPol().getListeProfesseur().size()];
			for(int i=0;i<res.length;i++){
				res[i]=this.fle.getPol().getListeProfesseur().get(i).getNom();
			}
			return res;
		}
 
		public JLabel getJlCle() {
			return jlCle;
		}
 
		public JButton getJbAjouter() {
			if(jbAjouter==null){
				jbAjouter= new JButton("Ajouter");
				jbAjouter.setPreferredSize(new Dimension(70,30));
				jbAjouter.addActionListener(new ActionListener(){
 
					public void actionPerformed(ActionEvent arg0) {
						// TODO Raccord de méthode auto-généré
						Formation nouvelle=null;
						if(etudiantIsSelected()){
							String clef = getClef();
							//String prof = FenetreAjouterFormation.this.jcbProf.getSelectedItem().toString();
							String type = getTypeCours();
							String loca = getLocalisation();
							//System.out.println(clef+" "+prof+" "+type);
 
							Professeur p = FenetreAjouterFormation.this.fle.getPol().getProfesseur(FenetreAjouterFormation.this.jcbProf.getSelectedIndex());
							ArrayList<Etudiant> e = getListEtudiant();
 
							nouvelle = new Formation(clef,type,loca);
							nouvelle.affecterProfesseur(p);
							nouvelle.affecterEtudiants(e);
							FenetreAjouterFormation.this.fle.getPol().ajouterFormation(nouvelle);
 
							FenetreAjouterFormation.this.setVisible(false);
							FenetreAjouterFormation.this.fle.setEnabled(true);
							FenetreAjouterFormation.this.fle.setVisible(true);
							FenetreAjouterFormation.this.fle.rafraichir();
 
						}
 
					}
 
				});
			}
			return jbAjouter;
		}
		public boolean etudiantIsSelected(){
			boolean res=false;
			if(this.jlEtudiant.getSelectedIndex()!=-1){
				res=true;
			}else{
				res=false;
			}
			return res;
		}
		public ArrayList<Etudiant> getListEtudiant(){
			ArrayList<Etudiant> res= new ArrayList<Etudiant>();
 
			int[] selection = this.jlEtudiant.getSelectedIndices();
 
			for(int i=0; i<selection.length;i++){
				res.add(this.fle.getPol().getListeEtudiant().get(i));
			}
 
			return res;
		}
		public String getLocalisation(){
			String res="";
			res=(String) FenetreAjouterFormation.this.jcbLoca.getSelectedItem();
			return res;
		}
		public String getTypeCours(){
			String res ="";
 
			if(FenetreAjouterFormation.this.jcbCle2.getSelectedIndex()==0){
				res="Particulier";
			}else{
				if(FenetreAjouterFormation.this.jcbCle2.getSelectedIndex()==1){
					res="Semi-privé";
				}else{
					res="Groupe";
				}
			}
			return res;
		}
		public String getClef(){
			String res="";
			String clef1 = FenetreAjouterFormation.this.jcbCle1.getSelectedItem().toString();
			String clef2 = FenetreAjouterFormation.this.jcbCle2.getSelectedItem().toString();
			//Obligé de faire comme ceci, sinon 
			String clef3 =test01.Nombre.convIntToString((FenetreAjouterFormation.this.fle.getPol().getNbFormation())+1);
 
			res=clef1+clef2+clef3;
			return res;
		}
 
		public JButton getJbReini() {
			if(jbReini==null){
				jbReini=new JButton("Réinitialiser");
				jbReini.setPreferredSize(new Dimension(70,30));
			}
			return jbReini;
		}
 
		public JComboBox getJcbLoca() {
			if(jcbLoca==null){
				String[] choix = {"Polyac","En entreprise"};
				jcbLoca=new JComboBox(choix);
				jcbLoca.setMaximumSize(new Dimension(120,30));
				jcbLoca.setMinimumSize(new Dimension(120,30));
			}
			return jcbLoca;
		}
 
		public JLabel getJlLoca() {
			return jlLoca;
		}
 
		public JList getJlEtudiant() {
			if(jlEtudiant==null){
				jlEtudiant=new JList();
				jlEtudiant.setMinimumSize(new Dimension(100,100));
				jlEtudiant.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
				jlEtudiant.setListData(this.fle.getPol().listeIdentifiantsEtudiants());
				jlEtudiant.setToolTipText("Maintenir CRTL pour effectuer une selection de plusieurs étudiants");
			}
			return jlEtudiant;
		}
 
		public JLabel getJlListe() {
			return jlListe;
		}
 
		public PaneListeFormation getFle() {
			return fle;
		}
}
Merci d'avance d'y avoir jeter un petit coup d'oeil.