IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AWT/Swing Java Discussion :

[Debutante] pb d'affichage d'une fenêtre


Sujet :

AWT/Swing Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    296
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 296
    Par défaut [Debutante] pb d'affichage d'une fenêtre
    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)

  2. #2
    Membre Expert Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Par défaut
    la réponse est la :

    at my_sql.Mysql.AjouterSActionPerformed(Mysql.java:593)

    A toi de voir ce qu'est la ligne 593! On peux pas le deviner à ta place. Vu l'erreur tu pourrais quand meme faire un effort de recherche, car ton erreur ne doit pas etre trop compliquer à comprendre vu que c'est un NULLPOINTER!

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    296
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 296
    Par défaut
    Si je l'avais trouvé, je n'aurais pas posté.

  4. #4
    Membre émérite
    Avatar de sironimo
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    669
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Mai 2004
    Messages : 669
    Par défaut
    Alors tu dois apprendre à bien regarder le message d'erreur. Il t'indique souvent la ligne qui pose problème

    On peut savoir ce qu'il y a à la ligne en question?

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    296
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 296
    Par défaut
    A la ligne en question il y a :

  6. #6
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    296
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 296
    Par défaut
    Et a la ligne 566 il a y:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      private void AjouterSActionPerformed(java.awt.event.ActionEvent evt) {
    Et a 494 il y a:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    AjouterSActionPerformed(evt);

  7. #7
    Membre émérite
    Avatar de sironimo
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    669
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Mai 2004
    Messages : 669
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
     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();
    				}
             }
         });
    Essaie de rajouter ton bouton a ton JDialog après l'actionListener()

    --> mettre jDialog1.add(ok); à la fin du code que j'ai copié et surtout enlevé la première ligne du code que j'ai mis.

Discussions similaires

  1. Affichage d'une fenêtre sans la barre d'outil
    Par itrione dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 20/06/2006, 23h43
  2. [C# 2]Affichage d'une fenêtre d'attente
    Par sarapis dans le forum Windows Forms
    Réponses: 6
    Dernier message: 03/06/2006, 00h18
  3. [C#] Problème d'affichage d'une fenêtre (event Load)
    Par PB-W dans le forum Windows Forms
    Réponses: 3
    Dernier message: 10/03/2006, 13h48
  4. pb affichage dans une fenêtre
    Par Mat 74 dans le forum Windows
    Réponses: 8
    Dernier message: 27/11/2005, 23h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo