Bonjour à tous,
J'aimerai positionner des objets tels que des boutons, des tableau ou encore des zone de texte. Pour cela j'utilise GridBagConstraints etGridBagLayout, mais je n'y parviens pas. Je suis nouveau sur le forum, et débutant en JAVA. Je fais donc appel à ce forum, qui ma déjà servi plus d'une fois, pour essayer de résoudre ce problème. En vous remerciant, Rémy.
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 GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; this.setLayout(new GridBagLayout()); gbc.gridy = 0; gbc.gridx = 1; gbc.weightx = 5; this.add(new JLabel("Accéléromètres"), gbc); gbc.gridy = 0; gbc.gridx = 2; gbc.weightx = 5; this.add(b_new_accel, gbc); b_new_accel.addActionListener(this); gbc.gridy = 0; gbc.gridx = 3; gbc.weightx = 5; this.add(b_del_accel, gbc); b_del_accel.addActionListener(this); gbc.gridy = 1; gbc.gridx = 1; gbc.weightx = 5; this.add(new JLabel("Jauge 1/4 pont"), gbc); gbc.gridy = 1; gbc.gridx = 2; gbc.weightx = 5; this.add(b_new_jauge, gbc); b_new_jauge.addActionListener(this); gbc.gridy = 1; gbc.gridx = 3; gbc.weightx = 5; this.add(b_del_jauge, gbc); b_del_jauge.addActionListener(this); gbc.gridy = 2; gbc.gridx = 1; gbc.weightx = 5; this.add(p_acc, gbc); gbc.gridy = 2; gbc.gridx = 1; gbc.weightx = 5; p_acc.add(table_accel.getTableHeader(), gbc); gbc.gridy = 2; gbc.gridx = 1; gbc.weightx = 5; p_acc.add(table_accel, gbc); gbc.gridy = 2; gbc.gridx = 2; gbc.weightx = 5; p_acc.add(table_jauge.getTableHeader(), gbc); gbc.gridy = 2; gbc.gridx = 2; gbc.weightx = 5; p_acc.add(table_jauge, gbc);







Répondre avec citation
Partager