Salam Alikom
je début avec Java là, et j'ai un code qui ne donne pas le résultat espéré :
Normalement je dois avoir un frame avec trois panel, p1 au nord, p2 au centre, et p3 au sud. Mais au lieu de ça j'obtiens les 3 panels répartit horizontalement sur la même ligne. quelqu'un peut m'expliquer pq ?
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 import java.awt.*; class usepanel { public static void main(String argv[]) { Window w = new Frame("3 Panels"); w.setLayout(new BorderLayout()); Panel p1 = new Panel(); p1.setLayout(new FlowLayout()); p1.add(new Label("P1 : 1")); p1.add(new Label("P1 : 2")); p1.add(new Label("P1 : 3")); w.add("North", p1); Panel p2 = new Panel(); p1.setLayout(new FlowLayout()); p1.add(new Label("P2 : 1")); p1.add(new Label("P2 : 2")); p1.add(new Label("P2 : 3")); w.add("Center", p2); Panel p3 = new Panel(); p1.setLayout(new FlowLayout()); p1.add(new Label("P3 : 1")); p1.add(new Label("P3 : 2")); p1.add(new Label("P3 : 3")); w.add("South", p3); w.show(); w.pack(); } }
Partager