Salut à tous!

Je débute en Java (enfin j'ai quelques notions déjà). Je me suis attaqué à une interface Swing. J'ai une petite question sur le GridBagLayout.

Voici 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
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
 
 
public class MenuPanel extends JPanel {
 
	public MenuPanel() {
 
		this.setSize(250, 568);
		this.setBackground(new Color(255, 255, 255));
 
		this.setLayout(new GridBagLayout());
 
		JLabel menuLabel = new JLabel("Menu", SwingConstants.CENTER);
		menuLabel.setFont(new Font("Serif", Font.PLAIN, 16));
 
 
 
 
		JButton addButton = new JButton("Ajouter un Contact");
		addButton.setPreferredSize(new Dimension(180, 20));
 
		JButton manageButton = new JButton("Gérer les contacts");
		manageButton.setPreferredSize(new Dimension(180, 20));
 
		JButton optionsButton = new JButton("Options");
		optionsButton.setPreferredSize(new Dimension(180, 20));
 
		JButton quitButton = new JButton("Quitter");
		quitButton.setPreferredSize(new Dimension(180, 20));
 
 
 
		GridBagConstraints gbc = new GridBagConstraints();
 
		gbc.gridx = 0;
		gbc.gridy = 0;
                            gbc.gridheight = 1;
                            gbc.gridwidth = 1;
                            gbc.anchor = GridBagConstraints.FIRST_LINE_START;
                            gbc.insets = new Insets(10, 10, 0, 10);
                            this.add(addButton, gbc);
 
                            gbc.gridx = 0;
                            gbc.gridy = 1;
                            gbc.gridheight = 1;
                            gbc.gridwidth = 1;
                            gbc.anchor = GridBagConstraints.FIRST_LINE_START;
                            gbc.insets = new Insets(10, 10, 0, 10);
                            this.add(manageButton, gbc);
 
                            gbc.gridx = 0;
                            gbc.gridy = 3;
                            gbc.gridheight = 1;
                            gbc.gridwidth = 1;
                            gbc.anchor = GridBagConstraints.FIRST_LINE_START;
                            gbc.insets = new Insets(10, 10, 0, 10);
                            this.add(optionsButton, gbc);
 
                            gbc.gridx = 0;
                            gbc.gridy = 4;
                            gbc.gridheight = 1;
                            gbc.gridwidth = 1;
                            gbc.anchor = GridBagConstraints.FIRST_LINE_START;
                            gbc.insets = new Insets(10, 10, 0, 10);
                            this.add(quitButton, gbc);
 
	}
 
 
}
Ce Panel fait partie d'une JFrame en BorderLayout.WEST. Le soucis est que les boutons s'affichent au centre du Panel et non pas en haut du Panel. Comment je peux faire pour les mettre en haut?

Autre question, j'ai sauté une case avec la propriété gridy en passant de 1 à 3 mais le Layout ne fait pas sauter la case au bouton. Je comprends pas pourquoi.

Merci de votre aide^^