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
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 
class Bibliotheque extends JFrame {
	private int numInterface=0;
	private JPanel pane;
	private GridBagLayout gridbag;
	private GridBagConstraints constraints;
 
	public Bibliotheque() {
		super("La Bibliotheque de Villeneuve Saint Georges");
		System.out.println("Starting Bibliotheque...");
		setSize(400, 400);
		gridbag=new GridBagLayout();
		constraints=new GridBagConstraints();
		pane=new JPanel();
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				dispose();
				System.out.println("fin du programme");
				System.exit(0);
			}
		});
		MiseAJour(numInterface); --->appele à la fonction si dessous
		setVisible(true);
	}
 
 
	void buildConstraints(GridBagConstraints gbc,int gx,int gy,int gw,int gh,int wx,int wy){
		gbc.gridx=gx;
		gbc.gridy=gy;
		gbc.gridwidth=gw;
		gbc.gridheight=gh;
		gbc.weightx=wx;
		gbc.weighty=wy;
	}
 
 
	void MiseAJour(int numInterface){
		if (numInterface==0){
			pane.setLayout(gridbag);
			buildConstraints(constraints,0,0,1,1,100,100); -----> crée la grille en passant par la fonction si dessus
			JLabel gestAdhLbl=new JLabel("mdr");
			gridbag.setConstraints(gestAdhLbl,constraints);
			add(gestAdhLbl);
 
			setContentPane(pane);
			constraints.fill=GridBagConstraints.BOTH;
 
		}
	}
 
	public static void main(String args[]) {
		Bibliotheque bibli = new Bibliotheque();
 
	}
}
j'ouvre une nouvelle fenetre qui s'appelle Bibliothèque, je probleme c'est que j'integre un bouton sur la frame (sachan ke la grile changera dès l'appuie d'un bouton submit non presenté sur ce morceu de code

====>une erro tel que exception in thread main.....apprarait :/
MErci pour l'aide