Bonjour, voici mon 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
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
 
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
 
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
 
public class Cinter extends JFrame{
 
 
	JPanel panel = new JPanel();
 
	JButton b1 = new JButton("bouton1");
	JButton b2 = new JButton("bouton2");
	JButton b3 = new JButton("bouton3");
	JButton b4 = new JButton("bouton4");
	JButton b5 = new JButton("bouton5");
 
	JTextField infoField = new JTextField();
	JTextArea logArea = new JTextArea();
 
	/**
         * 
         */
	private static final long serialVersionUID = 1L;
 
 
	public Cinter()
	{
 
		GridBagLayout layout = new GridBagLayout();
		panel.setLayout(layout);
		panel.setSize(640,480);
 
		panel.add(b1, new GBC(0,0).setFill(GridBagConstraints.HORIZONTAL));
		panel.add(b2, new GBC(1,0).setFill(GridBagConstraints.HORIZONTAL));
		panel.add(b3, new GBC(2,0).setFill(GridBagConstraints.HORIZONTAL));
 
		panel.add(b4,new GBC(0,1,3,1).setFill(GridBagConstraints.HORIZONTAL));
 
		panel.add(b5,new GBC(2,2,1,1).setFill(GridBagConstraints.HORIZONTAL));
 
		/*
		panel.add(selectServeur, new GBC(0,0,1,2).setInsets(0, 0, 400, 0).setWeight(100, 100));
		panel.add(infoField,new GBC(1,0));
		panel.add(selectAction, new GBC(1,1));
		panel.add(logArea, new GBC(1,2));
		*/
		add(panel);
		setSize(640, 480);
		setVisible(true);
 
	}
 
	public static void main(String[] args)
	{
		new Cinter();
	}
 
}
J'utilise une classe gbc que voici :

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
package fr.viv.view;
 
import java.awt.*;
 
public class GBC extends GridBagConstraints {
 
	public GBC (int gx, int gy)
	{
		this.gridx=gx;
		this.gridy=gy;
	}
 
	public GBC (int gx, int gy, int gwx, int gwy)
	{
		this.gridx=gx;
		this.gridy=gy;
		this.gridwidth=gwx;
		this.gridheight=gwy;
	}
 
	public GBC setAnchor(int anchor)
	{
		this.anchor=anchor;
		return this;
	}
 
	public GBC setFill (int fill)
	{
		this.fill=fill;
		return this;
	}
 
	public GBC setWeight(int wx, int wy)
	{
		this.weightx=wx;
		this.weighty=wy;
		return null;
	}
 
	/* Espacement dans toutes les directions entre les cellules */
	public GBC setInsets(int distance)
	{
		this.insets=new Insets(distance,distance,distance,distance);
		return this;
	}
 
	public GBC setInsets(int haut, int bas, int droite, int gauche)
	{
		this.insets= new Insets(haut,gauche,bas,droite);
		return this;
	}
 
	//Agrandissement du composant
	public GBC setIpad(int x, int y)
	{
		this.ipadx=x;
		this.ipady=y;
		return this;
	}
 
}
Je vousdrais que lorsque l'on agrandit la fenetre les composants suivent. de plus, je ne comprends pas bien la notion de poids des composants.
Merci de votre aide.