Bonjour à toutes et à tous,
en fait je dispose des composants dans une JFrame grâce au GridBagLayout, c'est la première fois que j'utilise et c'est un peu la lutte
Mon code :
Voici en PJ ce que j'ai et ce que je voudrai obtenir. En fait, je cherche à réduire l'espace vertical entre ma TextArea et le label au nord et les boutons au sud... Bref que la TextArea prennent tout pleins de place,
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 getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gbc= new GridBagConstraints(); gbc.weightx= 1; gbc.weighty= 1; /** LABEL NORD **/ gbc.anchor= GridBagConstraints.PAGE_START; gbc.fill = GridBagConstraints.NONE; gbc.gridx= 1; gbc.gridy= 0; gbc.gridwidth=2; gbc.gridheight= 1; getContentPane().add(jl_texte, gbc); /** TEXTAREA **/ gbc.anchor= GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.BOTH; gbc.gridx= 2; gbc.gridy= 1; gbc.gridwidth= 3; gbc.gridheight= 3; getContentPane().add(js_texte, gbc); /** BOUTONS SUD **/ gbc.anchor= GridBagConstraints.PAGE_END; gbc.fill= GridBagConstraints.NONE; gbc.gridx= 0; gbc.gridy= 8; gbc.gridwidth= 2; gbc.gridheight= 1; getContentPane().add(jb_stats, gbc); gbc.gridx= 2; gbc.gridwidth= 2; getContentPane().add(jb_parcourir, gbc); gbc.gridx=4; gbc.gridwidth= 2; getContentPane().add(jb_valider, gbc);
![]()
Partager