Bonjour a tous ,
Voilà j'essaie d'organiser une JPanel mais je n'y arrive pas malgré avoir essayer avec l'outil GridLayout (je pense que je l'utilise mal)
De plus comme vous pourrez le voir le Jbutton que j'ai placé est excessivement grand et mon JPanel(contenant des label et textfield) trop petit!
POuvez-vous me donner un coup de pouce pour m'en sortir!
Merci pour toute réponse !

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
86
87
88
89
90
91
92
public class PanelElement {
 
	private JPanel panelID;
	private JPanel panelSN;
	private JPanel panelLN;
 
 
	public PanelElement(){
		this.panelID = createPanelID();
		this.panelSN = createPanelShortName();
		this.panelLN = createPanelLongName();
	}
 
	public static JPanel createPanelID(){
		JPanel panelID = new JPanel(new GridLayout(1,2));
		JLabel infoId = new JLabel("Id");
		JTextField textID = new JTextField(null);
		textID.setPreferredSize(new Dimension(1, 1));
		panelID.add(infoId);
		panelID.add(textID);
		return panelID;
	}
 
	public static JPanel createPanelShortName(){
		JPanel panelShortName = new JPanel(new GridLayout(1,2));
		JLabel infoShortName = new JLabel("ShortName");
		JTextField textShortName = new JTextField(null);
		textShortName.setMaximumSize( new Dimension(1,1));
		panelShortName.add(infoShortName);
		panelShortName.add(textShortName);
		return panelShortName;
	}
 
	public static JPanel createPanelLongName(){
		JPanel panellongName = new JPanel(new GridLayout(1,2));
		JLabel infolongName = new JLabel("longName");
		JTextField textlongName = new JTextField(null);
		textlongName.setMaximumSize( new Dimension(1,1));
		panellongName.add(infolongName);
		panellongName.add(textlongName);
		return panellongName;
	}
 
 
	public  JPanel panelInfo(){
 
		PanelElement element = new PanelElement();
 
		JPanel allPanel= new JPanel(new GridLayout(10,1));
 
 
		/*ajout de tout les panel dans un panel principale*/
		allPanel.add(element.panelID,BorderLayout.WEST);
		allPanel.add(element.panelSN,BorderLayout.WEST);
		allPanel.add(element.panelLN,BorderLayout.WEST);
		allPanel.setBounds(0, 0, 500, 400);
 
		return allPanel;
	}
 
	public JPanel panelBouton(){
		JPanel boutonPanel = new JPanel(new GridLayout(1,3));
		JButton Bvalider = new JButton("Valider");
		//Bvalider.setBounds(0, 0, 10, 5);
		boutonPanel.add(Bvalider);
		return boutonPanel;
	}
 
	public JPanel panelComposite(){
		PanelElement element = new PanelElement();
		JPanel compositePanel = new JPanel(new GridLayout(2,1));
		compositePanel.add(element.panelInfo());
		compositePanel.add(element.panelBouton(),BorderLayout.SOUTH);
		return compositePanel;
 
 
	}
 
	public static void main(String[] args) {
		JFrame frame = new JFrame("Information Enseignement Normal");
		Container pane = frame.getContentPane( );
		pane.setLayout(new GridLayout(3,1));
 
		PanelElement element = new PanelElement();
 
		pane.add(element.panelComposite(),BorderLayout.CENTER);
		frame.setSize(500,800);
		//frame.pack();
		//frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		frame.setVisible(true);
	}
}