Bonjour,

Je ne comprends pas pourquoi mes composants ne se positionne pas en haut de ma fenetre.

J'utilise un gridbaglayout et une classe GBC que voici :

Je pense que je ne dois toujours pas utiliser correctement les parametres du GridBagConstraints, mais je ne vois pas ou.

Quelqu'un pourrait-il m'eclairer svp ?

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
 
import java.awt.*;
 
public class GBC extends GridBagConstraints {
 
	public GBC (int gx, int gy)
	{
		this.gridx=gx;
		this.gridy=gy;
	}
 
	public GBC (int gx, int gy, int gwx, int gwy)
	{
		this.gridx=gx;
		this.gridy=gy;
		this.gridwidth=gwx;
		this.gridheight=gwy;
	}
 
	public GBC setAnchor(int anchor)
	{
		this.anchor=anchor;
		return this;
	}
 
	public GBC setFill (int fill)
	{
		this.fill=fill;
		return this;
	}
 
	public GBC setWeight(int wx, int wy)
	{
		this.weightx=wx;
		this.weighty=wy;
		return null;
	}
 
	/* Espacement dans toutes les directions entre les cellules */
	public GBC setInsets(int distance)
	{
		this.insets=new Insets(distance,distance,distance,distance);
		return this;
	}
 
	public GBC setInsets(int haut, int bas, int droite, int gauche)
	{
		this.insets= new Insets(haut,gauche,bas,droite);
		return this;
	}
 
	//Agrandissement du composant
	public GBC setIpad(int x, int y)
	{
		this.ipadx=x;
		this.ipady=y;
		return this;
	}
 
}
et voici mon code :

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
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
 
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;
 
/* Fenetre servant à afficher les infos necessaire au lancement */
 
public class Cverif2 extends JFrame{
 
	JPanel myPane = new JPanel();
	JPanel myPaneCenter = new JPanel();
 
	JLabel titreChargement = new JLabel();
 
	JLabel verification = new JLabel();
	JLabel verification2 = new JLabel();
 
	public Cverif2()
	{
 
		BorderLayout myBorder = new BorderLayout();
 
		GridBagLayout myFlow = new GridBagLayout();
 
 
		myPane.setLayout(myBorder);
 
		titreChargement.setText(" MES GESTIONS");
 
		myPane.add(titreChargement, BorderLayout.NORTH);
 
 
		myPaneCenter.setLayout(myFlow);
 
		verification.setText("Connexion Bdd");
		verification2.setText("Connexion au serveur");
 
 
 
		myPaneCenter.add(verification,new GBC(0,0).setAnchor(GridBagConstraints.NORTH).setWeight(100, 100));
		myPaneCenter.add(verification2, new GBC(0,1).setWeight(100, 80));
 
		myPaneCenter.setBackground(Color.LIGHT_GRAY);
 
		myPane.add(myPaneCenter,BorderLayout.CENTER);
 
 
		myPane.setBackground(Color.LIGHT_GRAY);
 
		add(myPane);
 
		setAlwaysOnTop(true);
		setUndecorated(true);
		setResizable(false);
		setLocationRelativeTo(this.getParent());
		setSize(250,200);
		setVisible(true);
 
 
	}
 
	public static void main(String[] args) {
 
		new Cverif2();
	}
 
}
merci