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 :

Exception in thread


Sujet :

AWT/Swing Java

  1. #1
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2012
    Messages
    112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 112
    Points : 72
    Points
    72
    Par défaut Exception in thread
    Lorsque je fait un clic sur le jtree , l'erreur suivant s'affiche malgré que mon application s’exécute à 100 % :
    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
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at sd.expert.MenuPrincipale.jTree1MouseClicked(MenuPrincipale.java:1004)
    	at sd.expert.MenuPrincipale.access$400(MenuPrincipale.java:22)
    	at sd.expert.MenuPrincipale$5.mouseClicked(MenuPrincipale.java:229)
    	at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
    	at java.awt.Component.processMouseEvent(Component.java:6507)
    	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    	at java.awt.Component.processEvent(Component.java:6269)
    	at java.awt.Container.processEvent(Container.java:2229)
    	at java.awt.Component.dispatchEventImpl(Component.java:4860)
    	at java.awt.Container.dispatchEventImpl(Container.java:2287)
    	at java.awt.Component.dispatchEvent(Component.java:4686)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
    	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    	at java.awt.Container.dispatchEventImpl(Container.java:2273)
    	at java.awt.Window.dispatchEventImpl(Window.java:2713)
    	at java.awt.Component.dispatchEvent(Component.java:4686)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
    	at java.awt.EventQueue.access$000(EventQueue.java:101)
    	at java.awt.EventQueue$3.run(EventQueue.java:666)
    	at java.awt.EventQueue$3.run(EventQueue.java:664)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    	at java.awt.EventQueue$4.run(EventQueue.java:680)
    	at java.awt.EventQueue$4.run(EventQueue.java:678)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
    voila le code de mon Jtree
    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
     try { //Affichage jtree dans un nouveau onglet
    String nom_noeud = jTree1.getLastSelectedPathComponent().toString();
     
    if (evt.getClickCount()==2)
            {
     
                if ( nom_noeud .equals("Utilisateur"))// si le noeud de jtree est utilisateur 
                {
                    jTabbedPane1.addTab(nom_noeud ,Panel_New_User); 
     
    // remplissage de tableau des users dans le table user de jpanel new user
                    int k = Table_User.getColumnCount();
                    int l = Table_User.getRowCount();
                    Conexion1 A = new Conexion1();
                    //DefaultTableModel aModel = (DefaultTableModel) Table_User.getModel();
                     DefaultTableModel aModel = new DefaultTableModel (l,k){
        public boolean isCellEditable(int iRowIndex, int iColumnIndex)
        {
              return false;
     
        }
      };  
                    aModel.getDataVector().removeAllElements();  // pour vider la table et eliminer la redondance d'affichage
     
                        ResultSet ResultUser =      A.Conn().executeQuery("select * from users");
                        ResultSetMetaData rsmd = ResultUser.getMetaData();
                        int cols = rsmd.getColumnCount();
                        while (ResultUser.next())
     
                        {
                            Object[] row = new Object[cols];
                            for (int j = 0; j < row.length; j++) {
                                row[j] = ResultUser.getObject(j + 1);
     
                            }
                            aModel.addRow(row);
                        }
     
                        Table_User.setModel(aModel);
                        jTable1.setModel(aModel);
                        Table_User.repaint();
                         }
     
                }
                        // TODO add your handling code here:
                    } catch (SQLException | RemoteException ex) {
                        Logger.getLogger(MenuPrincipale.class.getName()).log(Level.SEVERE, null, ex);
     
     
            }
    j'ai fait un recherche sur internet mais j'ai rien trouvé concernant cette erreur

  2. #2
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Quelle est la ligne de code correspondant à
    at sd.expert.MenuPrincipale.jTree1MouseClicked(MenuPrincipale.java:1004)
    Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.

  3. #3
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2012
    Messages
    112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 112
    Points : 72
    Points
    72
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    String nom_noeud = jTree1.getLastSelectedPathComponent().toString();

  4. #4
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Tu dois traiter le cas où getLastSelectedPathComponent() te retourne null. Il n'y a pas nécessairement d'élément sélectionné dans le JTree au moment du clicked.
    Si tu a cliqué ailleurs que sur un élément ou si ton listener se déclenche avant le listenr gérant la sélection dans JTree.

    Si tu veux être notifié des éléments sélectionné, il y a des listener Spécifiques pour ça dans Jtree (TreeSelectionListener)

  5. #5
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2012
    Messages
    112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 112
    Points : 72
    Points
    72
    Par défaut
    La même erreur existe toujours même après le traitement de cas null

Discussions similaires

  1. Réponses: 8
    Dernier message: 11/05/2006, 20h32
  2. [JDIC]Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    Par kedare dans le forum Concurrence et multi-thread
    Réponses: 4
    Dernier message: 06/05/2006, 23h45
  3. [Classpath]Exception in thread "main" NoClassDefFound
    Par let_me_in dans le forum Général Java
    Réponses: 24
    Dernier message: 24/01/2006, 21h28
  4. Exception in thread "main" java.lang.ArrayIndexOut
    Par Poseidon62 dans le forum Concurrence et multi-thread
    Réponses: 6
    Dernier message: 04/11/2005, 02h38
  5. Réponses: 5
    Dernier message: 12/06/2002, 16h12

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