Bonjour,
je cherche à créer deux JPanel, gérés par un CardLayout ( classique ).
Pour l'instant j'avais déjà un premier panel où la disposition était impeccable, lorsque j'ajoute le CardLayout et que je fais un premier test sur ce panel, tout est affiché n'importe comment à l'intérieur. Mon premier réflexe a été de chercher un éventuel FlowLayout qui traîne mais rien...
Voila un extrait des attributs et de la construction, merci à ceux qui me liront :
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87 public class DaresMainFrame extends JFrame { /* * Constant title of the plugin window */ private static final String TITLE = "Reedition"; /* * Graphical elements : panels */ private JPanel labelPanel = new JPanel(new GridLayout(1,20)); private JPanel centerPanel = new JPanel(new GridLayout(1,20)); private JPanel southPanel = new JPanel(new BorderLayout()); //éléments au nord... //éléments au centre... //déclaration des menus ... /* * Label au sud de la fenetre HORS du CardLayout */ JLabel infoLabel = new JLabel("No selection"); public DaresMainFrame() { super(TITLE); /************** HierarchyViewer ****************/ JPanel HierarchyViewer = new JPanel(); /* * North elements */ HierarchyViewer.add(labelPanel, BorderLayout.NORTH); /* * Center elements */ HierarchyViewer.add(centerPanel, BorderLayout.CENTER); /************** RelationViewer ***********/ //deuxième JPanel en travaux JPanel relationsViewer = new JPanel(); /************** for both interfaces ******************/ //ajout des menus... /* * South elements */ this.add(southPanel, BorderLayout.SOUTH); southPanel.add(infoLabel,BorderLayout.WEST); /* * general */ this.setVisible(true); this.setSize(800,600); this.addComponentListener(new DaresComponentListener(this)); this.addWindowListener(new DaresWindowListener(this)); /********* creation of the CardLayout *********/ cards = new JPanel(new CardLayout()); cards.add(HierarchyViewer, HIERARCHY_VIEWER); cards.add(relationsViewer, RELATIONS_VIEWER); this.add(cards, BorderLayout.CENTER); Container contentPane = this.getContentPane(); contentPane.setLayout((CardLayout) (cards.getLayout())); CardLayout cl = (CardLayout) (cards.getLayout()); cl.show(cards, HIERARCHY_VIEWER); } /* * main function */ public static void main(String[] args) { DaresMainFrame window = new DaresMainFrame(); } }







Répondre avec citation
Partager