Bonjour à tous,
J'ai un panel pour lequel j'ai plusieurs composants et j'aimerais qu'il soit tous en haut de page.
Je voudrais ce résultat :
Avec ce code j'obtiens
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 this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTH; c.gridx = 0; c.gridy = 0; this.add(new JButton("1"), c); c.gridx = 1; c.gridy = 0; this.add(new JButton("2"), c); c.gridx = 0; c.gridy = 1; this.add(new JButton("3"), c); c.gridx = 1; c.gridy = 1; this.add(new JButton("4"), c); c.gridx = 0; c.gridy = 2; this.add(new JButton("5"), c); c.gridx = 1; c.gridy = 2; this.add(new JButton("6"), c);
Et si j'ajoute la ligne : c.weighty = 1.0;
J'obtiens :
Si quelqu'un peut m'aider ça serait génial.
Merci d'avance.
Partager