Bonjour,

J'ai un problème avec un GridLayoutBagLayout: je pense avoir fait ça correctement (dites-moi si c'est faux^^) mais la seconde ligne de ma grille ne s'affiche pas... Je pense que c'est dû au .setPreferredSize() de mes composants mais je n'en suis pas sûr.

Voici mon code: (j'ai supprimé les import et package pour alléger)
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
 
public class TodayArticles extends JPanel {
 
	public JPanel content = new JPanel();
 
 
	public TodayArticles() {
 
		this.setPreferredSize(getMaximumSize());
		content.setLayout(new GridBagLayout());
 
		JPanel headline = new JPanel();	
		headline.setPreferredSize(getPreferredSize());
		headline.setBackground(Color.orange);
 
		JPanel vertical = new JPanel();	
		vertical.setPreferredSize(getPreferredSize());
		vertical.setBackground(Color.cyan);
 
		JPanel botleft = new JPanel();
		botleft.setPreferredSize(getPreferredSize());
		botleft.setBackground(Color.green);
 
		JPanel botright = new JPanel();
		botright.setPreferredSize(getPreferredSize());
		botright.setBackground(Color.BLUE);
 
		GridBagConstraints gbc = new GridBagConstraints();
 
		gbc.gridx = gbc.gridy = 0;
		gbc.gridheight = gbc.gridwidth = 1;
		gbc.anchor = GridBagConstraints.BASELINE_LEADING;
 
		gbc.insets = new Insets(5, 5, 5, 5);
		content.add(headline, gbc);
 
		gbc.gridx = 1;
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.anchor = GridBagConstraints.BASELINE_LEADING;
		gbc.insets = new Insets(5, 5, 5, 5);
		content.add(vertical, gbc);
 
		gbc.gridx = 0;
		gbc.gridy = 1;
		gbc.anchor = GridBagConstraints.BASELINE_LEADING;
		gbc.insets = new Insets(5, 5, 5, 5);
		content.add(botleft, gbc);
 
		gbc.gridx = 1;
		gbc.gridwidth = gbc.gridheight = GridBagConstraints.REMAINDER;
		gbc.anchor = GridBagConstraints.BASELINE_LEADING;
		gbc.insets = new Insets(5, 5, 5, 5);
		content.add(botright, gbc);
 
 
 
		this.add(content);
	}
 
}
Merci d'avance!