Bonjour à tous,

J'ai créé une fenetre genre "formulaire".
J'ai voulu rajouter 2 champs de saisi qu'il n'y avait pas au départ (commentaire "MODIFICATION") et depuis les champs "commercial" et "Technicien" sont plus haut que les autres (???).

Quelqu'un a-t-il une idée de la raison ??

Voici le code source directement compilable (pour visualiser le problème):
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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
 
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
 
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
 
 
 
public class IhmDonneesEntreprise extends JDialog implements ActionListener {
 
	/** Gestionnaire de mise en pages */
	private GridBagLayout gridBagLayout = new GridBagLayout();
	private BorderLayout borderLayout = new BorderLayout();
	private GridBagConstraints c = new GridBagConstraints();
 
	/** Ensemble des JButton */
	private JButton ok, annuler;
 
	/** Ensemble des JPanel */
	private JPanel contentPane, machPane, datePane, entrPane, calPane,
			buttonPane, tempPane;
 
	/** Ensemble des JLabel */
	// Labels machPane
	private JLabel resMach = new JLabel("<html><p><b>Machine</b></p></html>");
	private JLabel labelRefMach = new JLabel("Ref : ");
	private JLabel labNumMach = new JLabel("N° : ");
	private JLabel labelChrono = new JLabel("N° Chrono :");
	private JLabel labelStatut = new JLabel("Statut :");
 
	// Labels datePane
	private JLabel labelDate = new JLabel("Dates (jj/mm/aa)");
	private JLabel labelDbt = new JLabel("*Début : ");
	private JLabel labelFin = new JLabel("*Fin : ");
	// Labels calPane
	private JLabel labelCal = new JLabel("*Commercial : ");
	private JLabel labelTech = new JLabel("*Technicien : ");
	// Labels Entreprise
	private JLabel labelEntreprise = new JLabel("<html><p><b>Entreprise</b></p></html>");
	private JLabel labelNomEntre = new JLabel("*Nom : ");
	private JLabel labelNumTelEntre = new JLabel("*N° Tel : ");
	private JLabel labelAdrEntre = new JLabel("*Adresse : ");
	private JLabel labelCodPostalEntre = new JLabel("*Code Postal : ");
	private JLabel labelContactEntre = new JLabel("*Contact : ");
	private JLabel labelInfoEntre = new JLabel("Info : ");
	/** Ensemble des JTextField */
	// Champs machPane
	public JTextField champsRefMach = new JTextField(10);
	public JTextField champsNumMach = new JTextField(10);
	public JTextField champsChrono = new JTextField(10);
	public JTextField champsStatut = new JTextField(10);
 
	// Champs datePane
	private JTextField champsDbt = new JTextField(8);
	private JTextField champsFin = new JTextField(8);
	// Champs calPane
	private JTextField champsCal = new JTextField(10);
	private JTextField champsTech = new JTextField(10);
	// Champs entrPane
	private JTextField champsNomEntre = new JTextField(10);
	private JTextField champsNumTelEntre = new JTextField(10);
	private JTextArea champsAdrEntre = new JTextArea(3, 20);
	private JTextField champsCodPostalEntre = new JTextField(5);
	private JTextField champsContactEntre = new JTextField(10);
	private JTextArea champsInfoEntre = new JTextArea(4, 20);
	private Toolkit tool = null;
 
 
 
	public boolean resultat = false;
 
 
	public IhmDonneesEntreprise(JFrame parent,String title)//Constructeur pour champs vides
		{
			super(parent,title,true);//On instancie un JDialog modal
 
			this.addWindowListener(new WindowAdapter() {
				public void windowIconified(WindowEvent e) {
				}
 
				public void windowClosing(WindowEvent e) 
				{
					System.exit(0);
				}
			});
 
 
			// Création et installation des composants (liste, boutons)
			creeComposants();
 
			// Initialisation de la taille et de la position de la fenêtre
			setup();
 
 
 
 
 
			setVisible(true);// On rend la fenêtre visible
		}
 
 
 
	/** Initialisation de la taille et de la position de la fenêtre */
	private void setup() {
		tool = this.getToolkit();//permet l'utilisation d'un beep sonore par
		// exemple
 
		//On adapte la taille de la fenetre principale à la résolution de
		// l'ecran Client
		Dimension tailleEcran = Toolkit.getDefaultToolkit().getScreenSize();
 
		//int largeur = (tailleEcran.width)/ 2;
		//int hauteur = (tailleEcran.height);
		int largeur = 500;
		int hauteur = 550;
 
		setSize(largeur, hauteur);
 
 
		int yPos = (tailleEcran.width ) / 4;
		int xPos = (tailleEcran.height ) / 15;
		setLocation(yPos, xPos);
 
		setResizable(true);
	}
 
	private void creeComposants() {
		/** Initialisation des JPanel */
		// init contentPane
		contentPane = (JPanel) this.getContentPane();
		contentPane.setLayout(gridBagLayout);
		// init machPane
		machPane = new JPanel();
		machPane.setLayout(gridBagLayout);
		// init datePane
		datePane = new JPanel();
		datePane.setLayout(gridBagLayout);
		// init calPane
		calPane = new JPanel();
		calPane.setLayout(gridBagLayout);
		// init entrPane
		entrPane = new JPanel();
		entrPane.setLayout(gridBagLayout);
		// init buttonPane
		buttonPane = new JPanel();
		buttonPane.setLayout(gridBagLayout);
 
		/** Initialisation des JButton */
		// bouton 'Ok'
		ok = new JButton("    Ok    ");
		ok.addActionListener(this);
		ok.setActionCommand("OK");
		// bouton 'Annuler'
		annuler = new JButton("Annuler");
		annuler.addActionListener(this);
		annuler.setActionCommand("ANNULER");
 
		// Ajout des labels
		c.anchor = GridBagConstraints.WEST;//accrochage du coin gauche à gauche du Panel principal
		c.fill = GridBagConstraints.BOTH;//on rempli vertical et horizontal
		c.insets = new Insets(0, 4, 0, 0);//ecart entre objet (haut,gauche,bas,droite)
 
		/** construction machPane */
		// label machine
		c.gridx = 0;//position en colonne
		c.gridy = 2; // Colonne 0, Ligne 2//position en ligne
		c.gridwidth = 1;//fusionnement de plusieurs cellules ou pas (1 = 1 cellule)
		c.gridheight = 1;//fusionnement de plusieurs cellules ou pas (1 = 1 cellule)
		gridBagLayout.setConstraints(resMach, c);
		machPane.add(resMach);
 
		// label ref
		c.gridx = 3;
		c.gridy = 4; // Colonne 3, Ligne 4
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(labelRefMach, c);
		machPane.add(labelRefMach);
		// champs ref
		c.gridx = 5;
		c.gridy = 4; // Colonne 5, Ligne 4
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(champsRefMach, c);
		machPane.add(champsRefMach);
		// label num
		c.gridx = 8;
		c.gridy = 4; // Colonne 8, Ligne 4
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(labNumMach, c);
		machPane.add(labNumMach);
		// champs num
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 10;
		gridBagLayout.setConstraints(champsNumMach, c);
		machPane.add(champsNumMach);
 
 
 
 
		/** contruction datePane */
		// Ajout des labels
		c.anchor = GridBagConstraints.WEST;
		c.gridwidth = 1;
		// label date
		c.gridx = 0;
		c.gridy = 2; // Colonne 0, Ligne 2
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(labelDate, c);
		datePane.add(labelDate);
		// label Début
		c.gridx = 0;
		c.gridy = 4; // Colonne 3, Ligne 4
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(labelDbt, c);
		datePane.add(labelDbt);
		// champs Début
		c.gridx = 5;
		c.gridy = 4; // Colonne 5, Ligne 4
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(champsDbt, c);
		datePane.add(champsDbt);
		// label Fin
		c.gridx = 7; // Colonne 7, Ligne 4
		c.gridwidth = 1;
		c.gridheight = 1;
		c.insets = new Insets(0, 4, 0, 0); //top, left, bottom, right
		gridBagLayout.setConstraints(labelFin, c);
		datePane.add(labelFin);
		// champs Fin
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 9; // Colonne 9, Ligne 4
		gridBagLayout.setConstraints(champsFin, c);
		datePane.add(champsFin);
 
 
 
		/** contruction calPane */
		// Ajout des labels
		c.anchor = GridBagConstraints.WEST;
		c.gridwidth = 1;
 
		/**+++++++++++++++++++++MODIFCATION+++++++++++++++++++++++++++*/
//			c.gridx = 0;
		c.gridx = 0;
		c.gridy = 2; // Colonne 0, Ligne 2
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(labelChrono, c);
		calPane.add(labelChrono);
		 // champs chrono
		c.gridx = 10;
		c.gridwidth = 1;
		c.gridheight = 1;
		c.insets = new Insets(10, 4, 10, 0); //top, left, bottom, right
		gridBagLayout.setConstraints(champsChrono, c);
		calPane.add(champsChrono);
		 // label statut
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 12;
		gridBagLayout.setConstraints(labelStatut, c);
		calPane.add(labelStatut);
		 // champs statut
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 20;
		gridBagLayout.setConstraints(champsStatut, c);
		calPane.add(champsStatut);
 
			/**+++++++++++++++++++++ FIN MODIFCATION+++++++++++++++++++++++++++*/
 
		// label commercial
		c.gridx = 0;
		c.gridy = 3; // Colonne 0, Ligne 2
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(labelCal, c);
		calPane.add(labelCal);
		// champs commercial
		c.gridx = 10;
		c.gridwidth = 1;
		c.gridheight = 1;
		c.insets = new Insets(0, 4, 0, 0); //top, left, bottom, right
		gridBagLayout.setConstraints(champsCal, c);
		calPane.add(champsCal);
		// label Technicien
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 12;
		gridBagLayout.setConstraints(labelTech, c);
		calPane.add(labelTech);
		// champs Technicien
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 20;
		gridBagLayout.setConstraints(champsTech, c);
		calPane.add(champsTech);
 
		/** construction entrPane */
		// Ajout des labels
		c.anchor = GridBagConstraints.NORTHWEST;
		c.fill = GridBagConstraints.NONE;
		c.insets = new Insets(4, 4, 0, 0); //top, left, bottom, right
		// label Entreprise
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 0;
		c.gridy = 2; // Colonne 0, Ligne 2
		gridBagLayout.setConstraints(labelEntreprise, c);
		entrPane.add(labelEntreprise);
		// label nom entreprise
		c.gridx = 0;
		c.gridy = 4; // Colonne 0, Ligne 4
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(labelNomEntre, c);
		entrPane.add(labelNomEntre);
		// champs nom entreprise
		c.gridx = 2;
		c.gridwidth = 1;
		c.gridheight = 1;
		gridBagLayout.setConstraints(champsNomEntre, c);
		entrPane.add(champsNomEntre);
 
		// label num tel
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 4; // Colonne 5, Ligne 4
		gridBagLayout.setConstraints(labelNumTelEntre, c);
		entrPane.add(labelNumTelEntre);
		// champs tel entreprise
		c.weightx = 1.0;
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 6; // Colonne 6, Ligne 4
		gridBagLayout.setConstraints(champsNumTelEntre, c);
		entrPane.add(champsNumTelEntre);
 
		// label adresse
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 0;
		c.gridy = 6; // Colonne 0, Ligne 6
		gridBagLayout.setConstraints(labelAdrEntre, c);
		entrPane.add(labelAdrEntre);
		// champs adresse entreprise
		c.gridwidth = GridBagConstraints.REMAINDER;
		c.gridx = 2;
		c.gridheight = 1;
		/** On souhaite un retour à ligne automatique : */
		champsAdrEntre.setLineWrap(true);
 
		/** On souhaite que les mots ne soient pas coupés : */
		champsAdrEntre.setWrapStyleWord(true);
		JScrollPane scrollAdr = new JScrollPane(champsAdrEntre);
		gridBagLayout.setConstraints(scrollAdr, c);
		entrPane.add(scrollAdr);
 
		// label code postal
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 0;
		c.gridy = 8; // Colonne 0, Ligne 8
		gridBagLayout.setConstraints(labelCodPostalEntre, c);
		entrPane.add(labelCodPostalEntre);
		// champs code postal entreprise
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 2; // Colonne 2, Ligne 8
		gridBagLayout.setConstraints(champsCodPostalEntre, c);
		entrPane.add(champsCodPostalEntre);
 
		// label contact entreprise
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 4; // Colonne 6, Ligne 8
		gridBagLayout.setConstraints(labelContactEntre, c);
		entrPane.add(labelContactEntre);
		// champs contact entreprise
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 6; // Colonne 6, Ligne 8
		gridBagLayout.setConstraints(champsContactEntre, c);
		entrPane.add(champsContactEntre);
 
		// label info Entreprise
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 0;
		c.gridy = 10; // Colonne 0, Ligne 10
		c.insets = new Insets(20, 4, 0, 0); //top, left, bottom, right
		gridBagLayout.setConstraints(labelInfoEntre, c);
		entrPane.add(labelInfoEntre);
		// champs contact entreprise
		c.gridwidth = GridBagConstraints.REMAINDER;
		c.gridx = 2; // Colonne 2, Ligne 10
		c.gridheight = 1;
 
		/** On souhaite un retour à ligne automatique : */
		champsInfoEntre.setLineWrap(true);
 
		/** On souhaite que les mots ne soient pas coupés : */
		champsInfoEntre.setWrapStyleWord(true);
 
		JScrollPane scrollInfo = new JScrollPane(champsInfoEntre);
		gridBagLayout.setConstraints(scrollInfo, c);
		entrPane.add(scrollInfo);
 
		/** Construction buttonPane */
		FlowLayout flow = new FlowLayout();
		buttonPane.setLayout(flow);
		buttonPane.add(ok);
		buttonPane.add(annuler);
 
		/** contruction contentPane */
		contentPane.add(machPane, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
				new Insets(0, 0, 9, 0), 1, 2));
		contentPane.add(datePane, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
				new Insets(0, 0, 9, 0), 1, 2));
		contentPane.add(calPane, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,
				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
				new Insets(2, 0, 9, 0), 1, 2));
		contentPane.add(entrPane, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0,
				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
				new Insets(2, 0, 0, 0), 1, 2));
		JLabel use = new JLabel("* Champs obligatoires");
		contentPane.add(use, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0,
				GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE,
				new Insets(10, 0, 0, 0), 1, 2));
		contentPane.add(buttonPane, new GridBagConstraints(0, 14, 1, 1, 0.0,
				0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
				new Insets(10, 0, 0, 0), 1, 2));
 
		contentPane.validate();
	}
 
 
 
	public void actionPerformed(ActionEvent evt) 
	{
		if (evt.getActionCommand() == "ANNULER") 
		{
			System.exit(0);
 
		}
		if (evt.getActionCommand() == "OK") 
		{
			System.exit(0);
		}	
	}
	public static void main(String arg[]) 
	{
		try {
					 UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
			}
		catch(Exception e) 
		   {
			 e.printStackTrace();
		   }
		  IhmDonneesEntreprise test = new IhmDonneesEntreprise(null, "test");
	}
 
 
 
}//checksum=445