Bonjour,

Dans une fenetre graphique, j'affiche un certain nombre de composants:
- un JLabel suivi d'un JTextField
- un JLabel suivi d'un JComboBox
- un JLabel suivi d'un JComboBox suivi d'un JTextField
- un JLabel suivi d'un JTextArea

En utilisant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
gbc.insets = new Insets(10, 10, 10, 10);
J'ai pu définir l'espacement entre chaque composant, mais le soucis c'est que j'aimerais que sur ma 3ème ligne que mon JTextField soit collé à mon JComboBox.

J'ai donc essayé un:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
gbc.insets = new Insets(0, 0, 0, 0);
juste avant l'insertion de mon JTextField dans mon conteneur puis de remettre la contrainte initiale juste après l'insertion, mais cela ne change rien :-(.

Voila le contenu de ma méthode :

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
 private JPanel buildContentPane1() {
        JPanel panel = new JPanel();
 
        panel.setLayout(new GridBagLayout());
 
        JLabel nameRuleLabel = new JLabel("Nom de la règle:");
        JLabel nameGroupRuleLabel = new JLabel("Nom du groupe de la règle:");
        JLabel whenRuleLabel = new JLabel("Conditions:");
        JLabel thenRuleLabel = new JLabel("Conséquences:");
 
        JTextField nameRuleValue = new JTextField();
        nameRuleValue.setColumns(20);
 
        //JTextArea whenRuleValue = new JTextArea();
        JTextArea thenRuleValue = new JTextArea();
 
        Object[] elements = new Object[] { "BCS", "RAP", "CV" };
        JComboBox nameGroupRuleValue = new JComboBox(elements);
 
        //JScrollPane scrollPane1 = new JScrollPane(whenRuleValue);
        //scrollPane1.setPreferredSize(new Dimension(200, 100));
        Object[] elements2 = new Object[] { "la langue du document est", "le code marque est"};
        JComboBox whenRuleComboBoxValue = new JComboBox(elements2);
 
        JTextField whenRuleValue = new JTextField();
        whenRuleValue.setColumns(3);
 
        JScrollPane scrollPane2 = new JScrollPane(thenRuleValue);
        scrollPane2.setPreferredSize(new Dimension(200, 100));
 
        JButton bouton = new JButton("Modifier la règle");
 
        thenRuleValue.setTransferHandler(new ToTransferHandler2(TransferHandler.COPY));
 
        GridBagConstraints gbc = new GridBagConstraints();
 
        gbc.insets = new Insets(10, 10, 10, 10);
 
        gbc.gridx = 0;
        gbc.gridy = 0;
        panel.add(nameRuleLabel, gbc);
 
        gbc.gridx = 1;
        gbc.gridy = 0;
 
        panel.add(nameRuleValue, gbc);
 
        gbc.gridx = 0;
        gbc.gridy = 1;
        panel.add(nameGroupRuleLabel, gbc);
 
        gbc.gridx = 1;
        gbc.gridy = 1;
        panel.add(nameGroupRuleValue, gbc);
 
        gbc.gridx = 0;
        gbc.gridy = 2;
        panel.add(whenRuleLabel, gbc);
 
        gbc.gridx = 1;
        gbc.gridy = 2;
        panel.add(whenRuleComboBoxValue, gbc);
 
        gbc.insets = new Insets(0, 0, 0, 0);
        gbc.gridx = 2;
        gbc.gridy = 2;
        panel.add(whenRuleValue, gbc);
 
        gbc.insets = new Insets(10, 10, 10, 10);
 
        gbc.gridx = 0;
        gbc.gridy = 3;
        panel.add(thenRuleLabel, gbc);
 
        gbc.gridx = 1;
        gbc.gridy = 3;
        panel.add(scrollPane2, gbc);
 
        gbc.gridx = 1;
        gbc.gridy = 4;
        panel.add(bouton, gbc);
 
 
        return panel;
    }
Une idée?

Merci :-)