Salut,
Mon pb est le suivant:

je dois ouvrir une fenêtre en cliquant sur un boutton d'une autre fenêtre, jusqu'ici tout est bon puis, ensuite,dans la nouvelle fenêtre que j'ouvre je dois avoir à ajouter un service en rempliant des champs et en cliquant sur un bouton ok qui va m'exécuter une méthode mais le pb c'est dans la nouvelle fenêtre que j'ouvre, j'arrive pas afficher mes boutons et label... bref elle est vide.

aidez svp

voila le code que j'ai fais:

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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
   private void AjouterSActionPerformed(java.awt.event.ActionEvent evt) {
 
	   getContentPane().setLayout(null);
 
       jDialog1.setTitle("Ajouter un Service");
       jDialog1.setResizable(false);
       addWindowListener(new java.awt.event.WindowAdapter() {
           public void windowClosing(java.awt.event.WindowEvent evt) {
               exitForm(evt);
           }
       });
   	jDialog1.setVisible(true);
   	 jDialog1.setSize(600,600);
 
	 jDialog1.setLayout(null);
 
	 jDialog1.add(ok);
     ok.setBounds(90, 140, 70, 23);
     ok.setText("Ok");
     ok.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
             try {
					okActionPerformed(evt);
				} catch (Exception e) {
					e.printStackTrace();
				}
         }
     });
 
     jDialog1.add(annuler);
     annuler.setBounds(190, 140, 80, 23);
     annuler.setText("Annuler");
     annuler.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
             annulerActionPerformed(evt);
         }
     });
 
     jLabel1.setText("Nom Enseignant :");
     jDialog1.add(jLabel1);
     jLabel1.setBounds(80, 20, 80, 15);
 
     jLabel2.setText("Module :");
     jDialog1.add(jLabel2);
     jLabel2.setBounds(80, 80, 90, 15);
 
     jLabel3.setText("Etat du paiement :");
     jDialog1.add(jLabel3);
     jLabel3.setBounds(80, 80, 90, 15);
 
     jLabel4.setText("Date de majoration :");
     jDialog1.add(jLabel4);
     jLabel4.setBounds(80, 80, 90, 15);
 
     jLabel5.setText("Heures prevues :");
     jDialog1.add(jLabel5);
     jLabel5.setBounds(80, 80, 90, 15);
 
     jLabel6.setText("Heures effectuees :");
     jDialog1.add(jLabel6);
     jLabel6.setBounds(80, 80, 90, 15);
 
     Nom_Enseignant.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
        	 Nom_EnseignantActionPerformed(evt);
         }
     });
 
     jDialog1.add(Nom_Enseignant);
     Nom_Enseignant.setBounds(80, 40, 200, 20);
 
     jDialog1.add(Module);
     Module.setBounds(80, 100, 200, 22);
 
     jDialog1.add(Etat_paiement);
     Etat_paiement.setBounds(80, 100, 200, 22);
 
     jDialog1.add(Date_majoration);
     Date_majoration.setBounds(80, 100, 200, 22);
 
     jDialog1.add(Heures_prevues);
     Heures_prevues.setBounds(80, 100, 200, 22);
 
     jDialog1.add(Heures_effectuees);
     Heures_effectuees.setBounds(80, 100, 200, 22);
 
 
     getContentPane().add(jDialog1);
     jDialog1.setBounds(0, 0, 400, 400);
 
     java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
     setBounds((screenSize.width-374)/2, (screenSize.height-232)/2, 374, 232);
 }
 
 private void Nom_EnseignantActionPerformed(java.awt.event.ActionEvent evt) {
 }
 
 private void annulerActionPerformed(java.awt.event.ActionEvent evt) {
    dispose();
 }
 
 private void okActionPerformed(java.awt.event.ActionEvent evt) throws Exception {//GEN-FIRST:event_okActionPerformed
 		String Enseignant = Nom_Enseignant.getText();
		String module = Module.getText();
		int EtatP = Integer.parseInt(Etat_paiement.getText());
		Date dateActuelle = new Date();
		int hp = Integer.parseInt(Heures_prevues.getText());
		int he = Integer.parseInt(Heures_effectuees.getText());
 
		AjoutS(Enseignant, module, EtatP , dateActuelle, hp, he);
		jDialog1.setVisible(true);
 
 }
et les erreurs que j'ai sont:
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
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at java.awt.Container.addImpl(Unknown Source)
	at java.awt.Container.add(Unknown Source)
	at javax.swing.JDialog.addImpl(Unknown Source)
	at java.awt.Container.add(Unknown Source)
	at my_sql.Mysql.AjouterSActionPerformed(Mysql.java:593)
	at my_sql.Mysql.access$2(Mysql.java:566)
	at my_sql.Mysql$3.actionPerformed(Mysql.java:494)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)