Bonjour,
Dans le cadre du dévelopment d'un programme censé listé un série de fichier présent sur un serveur distant, j'ajoute des box horizontales contenant les infos sur les fichiers. Cette box horizontales sont ajoutées à une box verticale. Le problème est que toute les box horizontale s'affiche au centre et je voudrais qu'elles s'affiche sur la gauche, voici un morceau de mon code, que dois-je faire ?
Et puis je fait juste un maFenetre.add(getUpdateList(),BorderLayout.CENTER);
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 private JScrollPane getUpdateList() { this.liste = new ArrayList<DownloadDescriptor>(); for (URL url : this.contenu) this.liste.add(new DownloadDescriptor(new JCheckBox(),url,"")); Box vertical = Box.createVerticalBox(); vertical.add(Box.createVerticalStrut(15)); int nullLine = 0; for (DownloadDescriptor dde : this.liste) { Box horizontal = ajouterLigne(dde); if (horizontal != null) { vertical.add(horizontal,BorderLayout.WEST); vertical.add(Box.createVerticalStrut(10)); } else nullLine++; } if(nullLine==this.liste.size()) this.noUpdate = true; JScrollPane paneau = new JScrollPane(vertical); JScrollBar bar = new JScrollBar(); bar.setUnitIncrement(10); paneau.setVerticalScrollBar(bar); return paneau; } private Box ajouterLigne(DownloadDescriptor dde) { if (!checkPlusTecent(dde)) return null; Box horizontal = Box.createHorizontalBox(); horizontal.add(Box.createHorizontalStrut(10)); horizontal.add(dde.getCheckbox()); horizontal.add(Box.createHorizontalStrut(10)); String urlComplète = dde.getUrl().toString(); String nomFichier = urlComplète.substring(urlComplète.lastIndexOf('/')+1,urlComplète.length()); horizontal.add(new JLabel(nomFichier)); horizontal.add(Box.createHorizontalStrut(10)); horizontal.add(new JLabel(dde.getCommentaire())); return horizontal; }








Répondre avec citation


Partager