Bonjour ,
comme l'indique le titre j'ai un soucis d'espace

Le code de ma fenêtre
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
 
 
	public CopyOfAffichage(){
		this.setSize(400,500);
		this.setLayout( new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
 
 
		this.add(new MyPanel());
		this.add(new MyPanel());
		this.add(new MyPanel());
		this.add(new MyPanel());
		this.add(new MyPanel());
		this.add(new MyPanel());
		this.add(new MyPanel());
		this.add(new MyPanel());
 
 
		this.setVisible(true);
 
	}

le code de my panel qui utilise un gridbaglayout
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
 
	public MyPanel(){
		super();
		this.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
 
		c.fill = GridBagConstraints.HORIZONTAL;
 
 
		un = new JLabel("Button 1");
		un.setOpaque(true);
		un.setBackground(new Color(191,28,28));
 
		c.weightx = 0.5;
		c.weighty = 100;
		//un.setPreferredSize(new Dimension(400, 500));
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridx = 0;
		c.gridy = 0;
		this.add(un, c);
 
		deux = new JLabel("Button 2");
		//deux.setPreferredSize(new Dimension(400, 500));
		deux.setOpaque(true);
		deux.setBackground(new Color(28,174,191));
		c.fill = GridBagConstraints.HORIZONTAL;
		c.weightx = 0.5;
		c.gridx = 1;
		c.gridy = 0;
		this.add(deux, c);
 
		trois = new JLabel("Button 3");
		trois.setOpaque(true);
		//trois.setize(new Dimension(400, 500));
		trois.setBackground(new Color(28,33,191));
		c.fill = GridBagConstraints.HORIZONTAL;
		c.weightx = 0.5;
		c.gridx = 2;
		c.gridy = 0;
		this.add(trois, c);

le rendu :

Nom : 803494rendu.jpg
Affichages : 260
Taille : 42,8 Ko

L'idée serait de ne pas avoir de blanc entre chaque lignes de JLabel

d'avance merci