[SWING] 2 layout imbriqués
Bonjour,
j'ai un JPanel JPA qui contient un JPanel JPB ...
Dans JPA : une bufferedImage et JPB
Dans JPB : 4 JLabel + 4JButton
ce code la marche :
Code:
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
|
public class JPA extends JPanel {
InternalImage monImage;
public JPA() {
monImage = new InternalImage(....);
monJPB = new JPB();
this.add(monJPB);
}
}
public class JPB extends JPanel {
public JPB() {
this.setLayout(new GridLayout(4, 2));
JLabel L1 = new JLabel("fgfdg");
JLabel L2 = new JLabel("ezrezezr");
JLabel L3 = new JLabel("fdfdfdf");
JLabel L4 = new JLabel("ezrzerzer");
this.add(L1);
B1 = new JButton();
this.add(B1);
this.add(L2);
B2 = new JButton();
this.add(B2);
this.add(L3);
B3 = new JButton();
this.add(B3);
this.add(L4);
B4 = new JButton();
this.add(B4); |
Je veux maitenant ajouter dans JPA une 3ème colonne pour afficher un bouton supplémentaire.
Je modifie donc comme ça :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
public class JPA extends JPanel {
InternalImage monImage;
public JPA() {
this.setLayout(new GridLayout(1, 3));
monImage = new InternalImage(....);
monJPB = new JPB();
this.add(monJPB);
this.add(new JButton("zzzzzzzz"));*/
}
} |
Et la, ben c'est n'importe quoi .... le panel JPB ne s'affiche plus du tout comme avant ...
Au secours, je ne comprends pas !